Guest User

Untitled

a guest
Mar 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import {timer} from "rxjs/observable/timer";
  2.  
  3. let observable = timer(1, 1000); //timer will emit an event each second
  4.  
  5. let subscribtion = observable.subscribe((data) => {
  6. //do stuff for each tick of stream data
  7. console.log(data);
  8. }, (reason) => {
  9. //when there was an error while watching observable
  10. }, () => {
  11. //do stuff when stream is complete
  12. });
  13.  
  14. //when you need to unsubscribe from this events you can call
  15. subscribtion.unsubscribe();
Add Comment
Please, Sign In to add comment