changes<Value> method
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 => useLocalInstance<PostsInteractor>().changes((state) => state.posts);
Implementation
Stream<StoreChange<Value>> changes<Value>(StoreMapper<Value, State> mapper) {
if (_isDisposed) {
throw const IllegalStateException(
message: 'Can\'t call changes after dispose.',
);
}
return _state.stream.map(
(event) => StoreChange(
mapper(event.previous ?? event.next!),
mapper(event.next as State),
),
);
}