Skip to content

Instantly share code, notes, and snippets.

@Coly010
Created March 2, 2021 11:35
Show Gist options
  • Select an option

  • Save Coly010/0521abdf6de56161bb3777164b503b84 to your computer and use it in GitHub Desktop.

Select an option

Save Coly010/0521abdf6de56161bb3777164b503b84 to your computer and use it in GitHub Desktop.
// 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