Search code examples
rxjsrxjs6rxjs-observables

How to complete combineLatest?


I use combineLatest to get latest values from each observables:

combineLatest$ = combineLatest(_block$, _field$);
    combineLatest$.subscribe(() => {
      console.log("Completed...");
    });

Then I have another observable that works until forkJoin$ sends data:

of(true).pipe(delay(1000), takeUntil(combineLatest$)).subscribe(() => console.log());

How to complete combineLatest$? And should I unsubscribe from of() or it will be destroyed automaticaly?


Solution

  • No. takeUntil will run teardown logic for you. Seems you're confusing the forkJoin semantics with combileLatest, they are quite different. In your particular case forkJoin$ has not the true forkJoin semantics; I guess you have to complete both _block$ and _field$ in order for combineLatest to complete.