onChange property

  1. @override
Stream<S> onChange

A stream that emits the current state when it changes.

Example

// First, create the Store
final store = new Store<int>(counterReducer, 0);

// Next, listen to the Store's onChange stream, and print the latest
// state to your console whenever the reducer produces a new State.
//
// We'll store the StreamSubscription as a variable so we can stop
// listening later.
final subscription = store.onChange.listen(print);

// Dispatch some actions, and see the printing magic!
store.dispatch("INCREMENT"); // prints 1
store.dispatch("INCREMENT"); // prints 2
store.dispatch("DECREMENT"); // prints 1

// When you want to stop printing the state to the console, simply
`cancel` your `subscription`.
subscription.cancel();

Implementation

@override
Stream<S> get onChange {
  final stream = _devToolsStore!.onChange
      .map((devToolsState) => devToolsState.currentAppState);

  return _distinct ? stream.distinct() : stream;
}