Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const customIntervalObservable = Observable.create(observer => {
- let count = 0;
- setInterval( () => {
- observer.next(count);
- if(count == 2){
- observer.complete();
- }
- if(count > 3){
- observer.error(new Error('Count is greater than 3!'));
- }
- count++;
- }, 1000)}
- );
- this.firstObsSubscription = customIntervalObservable.subscribe(
- data => {
- console.log(data);
- },
- error => {
- console.log(error);
- },
- () => {
- console.log('completed')
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement