getChangesForKey method
Get the change Stream for key
.
The first event on the returned Stream will be the current value
stored at key
. Whenever a new value is stored at key
, that value
will be sent out on the returned stream.
Implementation
Stream<V?> getChangesForKey(K key) {
// ignore: close_sinks
var changeController = StreamController<V?>();
changeController.add(_map[key]);
changeController
.addStream(_streamController.stream.where((Tuple2<K, V?> tuple) {
return key == tuple.item1;
}).map<V?>((Tuple2<K, V?> tuple) => tuple.item2));
return changeController.stream;
}