Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import {Subject} from "rxjs/Subject";
  2. import 'rxjs/add/operator/debounceTime';
  3.  
  4. const sub: Subject<number> = new Subject<number>();
  5.  
  6. sub.debounceTime(1000).subscribe((value: number) => {
  7. console.log('subscribe');
  8. console.log(value);
  9. });
  10.  
  11. sub.next(1);
  12. sub.next(2);
  13. sub.next(3);
  14.  
  15. setTimeout(() => {
  16. console.log('firsttimer');
  17. sub.next(4);
  18. }, 1100);
  19.  
  20. sub.next(5);
  21.  
  22. setTimeout(() => {
  23. console.log('secondtimer');
  24. sub.next(7);
  25. }, 2200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement