Skip to content

Instantly share code, notes, and snippets.

@pcurrivan
pcurrivan / inspectTime.ts
Last active March 4, 2020 02:16
Replacement for removed RxJS operator inspectTime
import { Observable } from 'rxjs';
// custom RxJS operator
// should be equivalent to the inspectTime operator that was removed from RxJS
export function inspectTime<T>(delay: number) {
return (source: Observable<T>): Observable<T> => {
return new Observable<T>(subscriber => {
let lastValue: T;
const action = () => subscriber.next(lastValue);
const throttle = ActionThrottle(action, delay);