How do I make an Observable Interval start immediately without a delay?

后端 未结 3 722
醉梦人生
醉梦人生 2020-12-20 11:13

I want my observable to fire immediately, and again every second. interval will not fire immediately. I found this question which suggested using startWith, whi

3条回答
  •  天涯浪人
    2020-12-20 11:44

    RxJs 6

    interval(100).pipe(startWith(0)).subscribe(() => { //your code }); 
    

    or with timer:

    import {timer} from 'rxjs/observable/timer';
    timer(0, 100).subscribe(() => {
    
        });
    

提交回复
热议问题