Skip to content

Instantly share code, notes, and snippets.

@cartant
Last active February 9, 2019 07:23
Show Gist options
  • Select an option

  • Save cartant/85f1c103696cb087b330b0fd79e2c27f to your computer and use it in GitHub Desktop.

Select an option

Save cartant/85f1c103696cb087b330b0fd79e2c27f to your computer and use it in GitHub Desktop.
import { MonoTypeOperatorFunction, Observable } from "rxjs";
import { tap } from "rxjs/operators";
export function debug<T>(): MonoTypeOperatorFunction<T> {
return source => new Observable<T>(subscriber => {
let index = -1;
return source.pipe(
tap(t => console.log(`[${++index}]: ${t}`))
).subscribe(subscriber);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment