pub struct DndScope { /* private fields */ }Expand description
An explicit lifetime for Dioxus signals and stores created outside a component scope.
A scope owns both storage flavors Dioxus state may allocate: ordinary
signals use UnsyncStorage, while a Store
keeps its subscription tree in SyncStorage. Create state inside
with, then retain a clone of the scope for exactly as long
as that state may be used. Storage is reclaimed when the last clone drops.
Use use_dnd_model instead for an app-wide model shared by windows. A
DndScope is intended for dynamic state whose lifetime really should end,
such as the contents owned by one spawned window.
with must run inside a Dioxus runtime, like the state constructors it
contains.
Do not drop the last scope clone while any owned read or write guard is
live. Unsynchronized storage cannot be recycled through an active
RefCell borrow and synchronized storage must wait for its lock guard.
use dioxus::prelude::*;
use dioxus_dnd::prelude::DndScope;
fn app() -> Element {
let scope = use_hook(DndScope::new);
let count = use_hook(|| scope.with(|| Signal::new(0)));
rsx! { "{count}" }
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DndScope
impl !Send for DndScope
impl !Sync for DndScope
impl !UnwindSafe for DndScope
impl Freeze for DndScope
impl Unpin for DndScope
impl UnsafeUnpin for DndScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().