Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. const customIntervalObservable = Observable.create(observer => {
  2. let count = 0;
  3. setInterval( () => {
  4. observer.next(count);
  5. if(count == 2){
  6. observer.complete();
  7. }
  8. if(count > 3){
  9. observer.error(new Error('Count is greater than 3!'));
  10. }
  11. count++;
  12. }, 1000)}
  13. );
  14.  
  15. this.firstObsSubscription = customIntervalObservable.subscribe(
  16. data => {
  17. console.log(data);
  18. },
  19. error => {
  20. console.log(error);
  21. },
  22. () => {
  23. console.log('completed')
  24. }
  25. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement