Created
May 23, 2019 00:43
-
-
Save rockydd/2bcc3b3a5966c4eeb19784a12952576a 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 { fromEvent, interval } from 'rxjs'; | |
import { tap, throttle } from 'rxjs/operators'; | |
const clicks = fromEvent(document, 'click'); | |
//const result = clicks.pipe(throttle(ev => interval(1000))); | |
const result = interval(2000).pipe(tap(x => console.log('v:', x)), throttle( i => clicks, {leading: true, trailing: true})); | |
result.subscribe(x => console.log(x)); | |
// trailing true, so emit the latest value when mouse clicked. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment