Skip to content

Instantly share code, notes, and snippets.

@caroso1222
Created January 9, 2019 03:42
Show Gist options
  • Save caroso1222/3ba55e119c04d20cb957487b98ec8b9d to your computer and use it in GitHub Desktop.
Save caroso1222/3ba55e119c04d20cb957487b98ec8b9d to your computer and use it in GitHub Desktop.
rxjs-log
const source = of('World');
// with tap
source.pipe(
tap(x => console.log(x))
).subscribe(x => {
this.doSomething(x);
});
// with map
source.pipe(
map(x => {
console.log(x);
return x;
})
).subscribe(x => {
this.doSomething(x);
});
// within the 'next' callback - bonus: log errors too
source.subscribe(x => {
console.log(x);
this.doSomething(x);
}, err => console.error(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment