Created
October 11, 2017 11:21
-
-
Save Atibaashraf/77e57721c2c2e92034686ac1a08d107b to your computer and use it in GitHub Desktop.
signature: do(nextOrObserver: function, error: function, complete: function): Observable - Transparently perform actions or side-effects, such as logging.
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 = Rx.Observable.of(1,2,3,4,5); | |
//transparently log values from source with 'do' | |
const example = source | |
.do(val => console.log(`BEFORE MAP: ${val}`)) | |
.map(val => val + 10) | |
.do(val => console.log(`AFTER MAP: ${val}`)); | |
//'do' does not transform values | |
//output: 11...12...13...14...15 | |
const subscribe = example.subscribe(val => console.log(val)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment