Last active
February 9, 2019 07:50
-
-
Save cartant/40166d96207056edf618f17515c51448 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
import { MonoTypeOperatorFunction } from "rxjs"; | |
import { tap } from "rxjs/operators"; | |
export function debug<T>(): MonoTypeOperatorFunction<T> { | |
let index = -1; | |
// Let's pretend that the map operator doesn't exist and that we have to use | |
// the tap operator and maintain our own internal state for the index, as the | |
// purpose of our operator is to show that the behaviour depends upon where | |
// the state is stored. | |
return tap(t => console.log(`[${++index}]: ${t}`)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment