Skip to content

Instantly share code, notes, and snippets.

@caroso1222
Created January 9, 2019 03:42
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