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:
Jonathan Kelley authored and GitHub committed 2025-10-04 01:55:52 -07:00
1 parent c56bac04f4
commit c29cef4ea3
40 files changed
+466 -697

No files matched your search

+2 -14
View File
@@ -2,15 +2,12 @@
//!
//! Each scope in dioxus has a single [Owner]
use generational_box::{AnyStorage, Owner, SyncStorage, UnsyncStorage};
use std::{
any::{Any, TypeId},
cell::RefCell,
};
use generational_box::{AnyStorage, Owner, SyncStorage, UnsyncStorage};
use crate::{innerlude::current_scope_id, Runtime, ScopeId};
/// Run a closure with the given owner.
///
/// This will override the default owner for the current component.
@@ -84,14 +81,5 @@ pub fn current_owner<S: AnyStorage>() -> Owner<S> {
return owner;
}
// Otherwise get the owner from the current scope
current_scope_id().expect("in a virtual dom").owner()
}
impl ScopeId {
/// Get the owner for the current scope.
#[track_caller]
pub fn owner<S: AnyStorage>(self) -> Owner<S> {
Runtime::with_scope(self, |cx| cx.owner::<S>()).unwrap_or_else(|e| panic!("{}", e))
}
crate::Runtime::current().current_owner()
}