Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. import {Subject} from "rxjs/Subject";
  2. import 'rxjs/add/operator/distinctUntilChanged';
  3.  
  4. const sub: Subject<number> = new Subject<number>();
  5.  
  6. sub.distinctUntilChanged().subscribe((val: number) => {
  7. console.log(val);
  8. });
  9.  
  10. sub.next(0);
  11. sub.next(0);
  12. sub.next(1);
  13. sub.next(2);
  14. sub.next(2);
  15. sub.next(2);
  16. sub.next(3);
  17.  
  18. // will output 0,1,2,3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement