behavior_subject_mixin 0.2.0 copy "behavior_subject_mixin: ^0.2.0" to clipboard
behavior_subject_mixin: ^0.2.0 copied to clipboard

A mixin that provides the state of StateNotifier as a stream of BehaviorSubject.

behavior_subject_mixin #

A mixin that provides the state of StateNotifier as a stream of BehaviorSubject.

Usage #

class CounterNotifier extends StateNotifier<int> with BehaviorSubjectMixin {
  CounterNotifier() : super(0);

  void increment() => state++;
}

void main() {
  final counterNotifier = CounterNotifier();
  final subscription = counterNotifier.stream.listen((currentState) {
    print('count is $currentState.');
  });

  counterNotifier.increment();
  counterNotifier.increment();
  counterNotifier.increment();

  Timer.run(subscription.cancel);
}

Output #

count is 0.
count is 1.
count is 2.
count is 3.
3
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A mixin that provides the state of StateNotifier as a stream of BehaviorSubject.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

rxdart, state_notifier

More

Packages that depend on behavior_subject_mixin