Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {timer} from "rxjs/observable/timer";
- let observable = timer(1, 1000); //timer will emit an event each second
- let subscribtion = observable.subscribe((data) => {
- //do stuff for each tick of stream data
- console.log(data);
- }, (reason) => {
- //when there was an error while watching observable
- }, () => {
- //do stuff when stream is complete
- });
- //when you need to unsubscribe from this events you can call
- subscribtion.unsubscribe();
Add Comment
Please, Sign In to add comment