Created
March 2, 2021 11:35
-
-
Save Coly010/0521abdf6de56161bb3777164b503b84 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Examples | |
| // We can use it on it's own to simply log out values to the console | |
| const obs$ = of('my test value'); | |
| obs$.pipe(debug()).subscribe(); | |
| // OUTPUT: | |
| // my test value | |
| We can also set up our own notification handlers if we prefer: | |
| const obs$ = of('my test value'); | |
| obs$ | |
| .pipe(debug({ next: (value) => console.log('my custom handler:', value) })) | |
| .subscribe(); | |
| // OUTPUT: | |
| // my custom handler: my test value | |
| const obs$ = throwError('uh oh'); | |
| obs$ | |
| .pipe(debug({ error: (value) => console.log('my error handler:', value) })) | |
| .subscribe(); | |
| // OUTPUT: | |
| // my error handler: uh oh | |
| const obs$ = of('my test value'); | |
| obs$ | |
| .pipe(debug({ complete: (value) => console.log('I completed') })) | |
| .subscribe(); | |
| // OUTPUT: | |
| // I completed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment