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:
1 parent
de87ba6548
commit
31f8bab20d
22 files changed
+106
-91
No files matched your search
@@ -63,6 +63,21 @@ impl<'a, T> std::ops::Deref for Scoped<'a, T> {
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
|
||||
pub struct ScopeId(pub usize);
|
||||
|
||||
impl ScopeId {
|
||||
/// The root ScopeId.
|
||||
///
|
||||
/// This scope will last for the entire duration of your app, making it convenient for long-lived state
|
||||
/// that is created dynamically somewhere down the component tree.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust, ignore
|
||||
/// use dioxus_signals::*;
|
||||
/// let my_persistent_state = Signal::new_in_scope(ScopeId::ROOT, String::new());
|
||||
/// ```
|
||||
pub const ROOT: ScopeId = ScopeId(0);
|
||||
}
|
||||
|
||||
/// A component's state separate from its props.
|
||||
///
|
||||
/// This struct exists to provide a common interface for all scopes without relying on generics.
|
||||
|
||||
Reference in new issue
Block a user