How to 'wait' for two observables in RxJS

前端 未结 7 1519
温柔的废话
温柔的废话 2020-12-13 12:14

In my app i have something like:

this._personService.getName(id)
      .concat(this._documentService.getDocument())
      .subscribe((response) => {
              


        
7条回答
  •  醉梦人生
    2020-12-13 12:29

    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.

提交回复
热议问题