Stream.takeUntil (or something) #8082
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
closed-obsolete
Closed as the reported issue is no longer relevant
core-n
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
I'm looking for something similar to takeWhile, but rather than performing the check before accepting the data, it performs the check after accepting the data.
I'm hitting this converting dart:html tests over to streams, in a number of the tests. The scenario is that they are listening to postMessage events until getting the one that they're looking for, then want to unsubscribe.
Alternatives are:
var complete = false;
window.onMessage.takeWhile((_) => !complete).listen((e) {
if (e.data == 'hello') {
complete = true;
}
});
Which is ugly because it requires an extra event to unsubscribe and will get any errors before that event.
And:
var subscription = null;
subscription = window.onMessage.listen((e) {
if (e.data == 'hello') {
subscription.cancel();
}
});
Which works, though the declaration of subscription is sort of ugly.
The text was updated successfully, but these errors were encountered: