changes<Value> method

Stream<StoreChange<Value>> changes<Value>(
  1. StoreMapper<Value, State> mapper
)

Stream of changes of values state

Using mapper you can select values you want to listen In contrast to updates this stream returns pairs of values - new state and previous state, so you can easily compare them if needed

Stream<StoreChange<StatefulData<List<Post>>?>> get postsChangesStream => getLocalInstance<PostsInteractor>().changes((state) => state.posts);

Implementation

Stream<StoreChange<Value>> changes<Value>(StoreMapper<Value, State> mapper) {
  if (_isDisposed) {
    throw IllegalStateException(
      message: 'Can\'t call changes after dispose.',
    );
  }

  return _state.stream.map((event) => StoreChange(
        mapper(event.previous ?? event.next!),
        mapper(event.next as State),
      ));
}