substateStream<Substate> method
Stream<SubstateChange<Substate> >
substateStream<Substate>(
- StateMapper<
State, StateBuilder, Substate> mapper
substateStream returns a stream to the state that is returned by the mapper function. For example: say my state object had a property count, then store.substateStream((state) => state.count), would return a stream that fires whenever count changes.
Implementation
Stream<SubstateChange<Substate>> substateStream<Substate>(
StateMapper<State, StateBuilder, Substate> mapper,
) =>
stream
.map((c) => SubstateChange<Substate>(
mapper(c.prev),
mapper(c.next),
))
.where((c) => c.prev != c.next);