Add ScopeId::ROOT (#1398)

* add ScopeId::ROOT

* replace ScopeId(0) with ScopeId::ROOT

---------

Co-authored-by: Jani Mustonen <jani.mustonen@taitounited.fi>
This commit is contained in:
Jani MustonenandJani Mustonen authored and GitHub committed 2023-08-25 08:31:23 -05:00
1 parent de87ba6548
commit 31f8bab20d
22 files changed
+106 -91

No files matched your search

+2 -2
View File
@@ -179,7 +179,7 @@ impl ScopeContext {
pub fn provide_root_context<T: 'static + Clone>(&self, context: T) -> T {
with_runtime(|runtime| {
runtime
.get_context(ScopeId(0))
.get_context(ScopeId::ROOT)
.unwrap()
.provide_context(context)
})
@@ -203,7 +203,7 @@ impl ScopeContext {
/// This is good for tasks that need to be run after the component has been dropped.
pub fn spawn_forever(&self, fut: impl Future<Output = ()> + 'static) -> TaskId {
// The root scope will never be unmounted so we can just add the task at the top of the app
let id = self.tasks.spawn(ScopeId(0), fut);
let id = self.tasks.spawn(ScopeId::ROOT, fut);
// wake up the scheduler if it is sleeping
self.tasks