Skip to content

Instantly share code, notes, and snippets.

@MattSPalmer
Last active May 11, 2020 04:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattSPalmer/41e1aa065c576ffa8ba1a3ba722048c9 to your computer and use it in GitHub Desktop.
Save MattSPalmer/41e1aa065c576ffa8ba1a3ba722048c9 to your computer and use it in GitHub Desktop.
debug subscriptions
const onSubscribe = (fn) => stream => Rx.defer(() => {
fn();
return stream;
})
const logOnSubscribe = message => onSubscribe(() => console.log(message));
Rx.interval(10e3).pipe(
switchMap(() => interval(200).pipe(
logOnSubscribe('subscribed to 200ms interval')
))
).subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment