pub struct Claim<'a, R: Reducer> { /* private fields */ }Expand description
A reducer being claimed, and what may still be said about it.
Produced by cx.state::<R>() during install. Ending the chain without
driven_by is not a half-finished feature - it is state
the UI owns outright, and the type says so: nothing drives it, so nothing
can be emitted to it.
Implementations§
Source§impl<'a, R: Reducer> Claim<'a, R>
impl<'a, R: Reducer> Claim<'a, R>
Sourcepub fn new(
scope: Scope,
bus: Option<&'a Rc<EventBus>>,
token: &'a UiThreadToken,
) -> Self
pub fn new( scope: Scope, bus: Option<&'a Rc<EventBus>>, token: &'a UiThreadToken, ) -> Self
For a context that hands features their scope - the contexts in
guinea-app, and nothing else. bus is the window’s, when the scope
is in one.
Sourcepub fn seed(self, state: R) -> Self
pub fn seed(self, state: R) -> Self
Starts from something other than R::default().
For a synchronous read - a setting already on disk - so the first frame shows real data instead of defaults followed by a round trip.
Sourcepub fn driven_by<A, F>(self, build: F) -> (Bound<R>, Addr<A>)
pub fn driven_by<A, F>(self, build: F) -> (Bound<R>, Addr<A>)
Creates the actor that drives this reducer, and installs it here.
The closure is handed the Push rather than fetching it, and the
actor’s lifetime becomes the scope’s - so a feature declares the whole
edge in one expression and owns none of the bookkeeping. The actor type
is inferred from what the closure returns; neither the reducer nor this
call has to name it.
The address comes back for wiring that is the actor’s own, such as
addr.subscribe_on::<M>(Bus::Global). The scope still owns the actor
and disposes it, and what it subscribed to ends with it.