Created
January 9, 2019 03:42
-
-
Save caroso1222/3ba55e119c04d20cb957487b98ec8b9d to your computer and use it in GitHub Desktop.
rxjs-log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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