Reputation: 822
I am looking for a recipe that would enable me to fulfill the following requirements.
I want to have a BehaviorSubject
like stream controller of a nullable type that:
To illustrate:
final controller = MyCustomController<int?>();
final sub1 = controller.stream.listen((val) => print("sub1: {value}");
controller.add(1);
final sub2 = controller.stream.listen((val) => print("sub2: {value}");
controller.add(null);
final sub3 = controller.stream.listen((val) => print("sub3: {value}");
The output would be:
sub1: 1
sub2: 1 // received current value on listening subscription2
sub1: null
sub2: null
// no value streamed at sub3 listen event because current value was null
Thanks a lot for your insights.
Upvotes: 0
Views: 18