Skip to content

Instantly share code, notes, and snippets.

@marcusradell
Created May 23, 2017 20:00
Show Gist options
  • Save marcusradell/e6a6fc67178e9cf05bc774f1a59a8b92 to your computer and use it in GitHub Desktop.
Save marcusradell/e6a6fc67178e9cf05bc774f1a59a8b92 to your computer and use it in GitHub Desktop.
const categoryFiltersStateStream = viewDataStream.switchMap(
checkboxesComponent => {
sub = checkboxesComponent.checkboxesStateStream.subscribe(
state => console.log("INNER EMIT 2", state, sub),
error => console.error("INNER ERROR 2", error),
// but also closes before first emit
() => console.log("INNER COMPLETE 2", sub)
);
return checkboxesComponent.checkboxesStateStream;
}
);
// this only emits once
categoryFiltersStateStream.subscribe(
state => console.log("EMIT ", state),
error => console.error("ERROR", error),
() => console.log("COMPLETE")
);
/* produces
INNER COMPLETE 2 Subscriber {closed: true, _parent: null, _parents: null, _subscriptions: null, syncErrorValue: null…}closed: truedestination: SafeSubscriberisStopped: truesyncErrorThrowable: falsesyncErrorThrown: falsesyncErrorValue: null_parent: null_parents: null_subscriptions: null__proto__: Subscription
INNER EMIT 2 (3) [Object, Object, Object] Subscriber {closed: true, _parent: null, _parents: null, _subscriptions: null, syncErrorValue: null…}
EMIT (3) [Object, Object, Object]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment