RXJS Wait for all observables in an array to complete (or error)

前端 未结 4 2181
走了就别回头了
走了就别回头了 2020-12-01 07:32

I\'m pushing observables into an array like such...

var tasks$ = [];
tasks$.push(Observable.timer(1000));
tasks$.push(Observable.timer(3000));
tasks$.push(Ob         


        
4条回答
  •  误落风尘
    2020-12-01 07:55

    For me this sample was best solution.

    const source = Observable.interval(500);
    const example = source.sample(Observable.interval(2000));
    const subscribe = example.subscribe(val => console.log('sample', val));
    

    So.. only when second (example) emit - you will see last emited value of first (source).

    In my task, I wait form validation and other DOM event.

提交回复
热议问题