I want my observable to fire immediately, and again every second. interval will not fire immediately. I found this question which suggested using startWith, which DOES fire immediately, but I then get a duplicate first entry.
interval
startWith
Rx.Observable.interval(1000).take(4).startWith(0).subscribe(onNext);
https://plnkr.co/edit/Cl5DQ7znJRDe0VTv0Ux5?p=preview
How can I make interval fire immediately, but not duplicate the first entry?
Before RxJs 6:
Observable.timer(0, 1000) will start immediately.
Observable.timer(0, 1000)
RxJs 6+
import {timer} from 'rxjs/observable/timer'; timer(0, 1000).subscribe(() => { ... });
1.4m articles
1.4m replys
5 comments
57.0k users