behavior_subject_mixin 0.2.0

Dart native js
Flutter Android iOS web

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
110
pub points
50%
popularity

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

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

heavenosk@gmail.com

License

MIT (LICENSE)

Dependencies

rxdart, state_notifier

More

Packages that depend on behavior_subject_mixin