pub struct StateStore { /* private fields */ }Expand description
What every component’s state, and every hook’s, is kept in between rebuilds. It lives in
the Runtime, under the place of the component that owns it.
Implementations§
Source§impl StateStore
impl StateStore
Sourcepub fn begin_build(&self)
pub fn begin_build(&self)
A rebuild of the tree is about to run. Every state it reaches is marked as reached.
Sourcepub fn end_frame(&self)
pub fn end_frame(&self)
The frame is done laying out: the states a rebuild did not reach are disposed, and the effects it asked for run.
Effects run after the tree is built and laid out, so that what they do — start a timer, read a controller, ask for another rebuild — never happens in the middle of building.
Sourcepub fn snapshot(&self) -> String
pub fn snapshot(&self) -> String
What every live state that opts in (State::save) wants kept across a restart, as
text: a line a state, its place, its type and what it saved.
frus run asks for this just before it stops the application to start a new build,
and hands it to StateStore::restore_from in the new one. A state is given back what
it saved only by the component at the same place, of the same type.
Sourcepub fn restore_from(&self, snapshot: &str)
pub fn restore_from(&self, snapshot: &str)
Takes a StateStore::snapshot: each state it holds is given back to the component
that mounts first at its place, with its type.
Sourcepub fn provide<T: 'static>(&self, value: Rc<T>)
pub fn provide<T: 'static>(&self, value: Rc<T>)
Makes value available to every component below as a service: the way an
application-wide object — a router, a repository — is reached from a build.