Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const customIntervalObservable = new Observable(observer => {
- let count = 0;
- setInterval( () => {
- //We can call the next method to emit a new value.
- observer.next(count);
- count++;
- if(count > 3) {
- observer.error(new Error('Count is greater 3!'));
- }
- }, 1000);
- });
- this.firstObsSubscription = customIntervalObservable.subscribe(data => {
- console.log(data);
- }, error => {
- // to handler the error we need to pass another argument to subscribe
- console.log(error.message);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement