move ScopeId methods to the runtime (#4723)
* move `ScopeId` methods to runtime methods * cargo check unused * wip... * wip... * fix consume context * fix test * guard hoisted * fix doc comment
This commit is contained in:
1 parent
c56bac04f4
commit
c29cef4ea3
40 files changed
+466
-697
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use dioxus_core::{ScopeId, Subscribers};
|
||||
use dioxus_core::{Runtime, ScopeId, Subscribers};
|
||||
use generational_box::BorrowResult;
|
||||
use std::{any::Any, cell::RefCell, collections::HashMap, ops::Deref, panic::Location, rc::Rc};
|
||||
|
||||
@@ -190,7 +190,9 @@ where
|
||||
}
|
||||
// Otherwise, create it
|
||||
// Constructors are always run in the root scope
|
||||
let signal = ScopeId::ROOT.in_runtime(|| T::initialize_from_function(self.constructor));
|
||||
let signal = dioxus_core::Runtime::current().in_scope(ScopeId::ROOT, || {
|
||||
T::initialize_from_function(self.constructor)
|
||||
});
|
||||
context
|
||||
.map
|
||||
.borrow_mut()
|
||||
@@ -274,9 +276,10 @@ impl GlobalLazyContext {
|
||||
|
||||
/// Get the global context for signals
|
||||
pub fn get_global_context() -> GlobalLazyContext {
|
||||
match ScopeId::ROOT.has_context() {
|
||||
let rt = Runtime::current();
|
||||
match rt.has_context(ScopeId::ROOT) {
|
||||
Some(context) => context,
|
||||
None => ScopeId::ROOT.provide_context(Default::default()),
|
||||
None => rt.provide_context(ScopeId::ROOT, Default::default()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user