mirror of https://github.com/AMT-Cheif/drift.git
Emit cached data in a later microtask
This commit is contained in:
parent
0e7ee6114b
commit
256b91f03f
|
@ -23,7 +23,12 @@ class StartWithValueTransformer<T> extends StreamTransformerBase<T, T> {
|
|||
..onListen = () {
|
||||
final data = _value();
|
||||
if (data != null) {
|
||||
controller.add(data);
|
||||
// Dart's stream contract specifies that listeners are only notified
|
||||
// after the .listen() code completes. So, we add the initial data in
|
||||
// a later microtask.
|
||||
scheduleMicrotask(() {
|
||||
controller.add(data);
|
||||
});
|
||||
}
|
||||
|
||||
subscription = stream.listen(
|
||||
|
|
Loading…
Reference in New Issue