Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Add whereType transformer #60

Merged
merged 7 commits into from
Feb 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/src/where_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,22 @@ class _WhereType<R> extends StreamTransformerBase<Null, R> {
StreamSubscription<Object> subscription;
controller.onListen = () {
if (subscription != null) return;
var valuesDone = false;
subscription = values.listen(
(value) {
if (value is R) controller.add(value);
},
onError: controller.addError,
onDone: () {
valuesDone = true;
subscription = null;
controller.close();
});
if (!values.isBroadcast) {
controller.onPause = subscription.pause;
controller.onResume = subscription.resume;
}
controller.onCancel = () {
var toCancel = subscription;
subscription?.cancel();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this used to return this value, not sure if it matters or not

Copy link
Contributor Author

@natebosch natebosch Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure either. There was some weirdness with an analyzer hint around this at one point that could have been why I had it in the fromHandlers implementation, and I copied most of that here.

subscription = null;
if (!valuesDone) return toCancel.cancel();
return null;
};
};
return controller.stream;
Expand Down