0

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?

  • So, I have tied to await 1 second and then if not response from server from all requests I should do operation –  Apr 25 '20 at 10:18

1 Answers1

0

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.

Zazaeil
  • 3,900
  • 2
  • 14
  • 31
  • Sorry it is type of variables I use `combineLatest`. Fixed –  Apr 25 '20 at 09:55
  • Yes, how to complete `combineLatest$` in advance? –  Apr 25 '20 at 09:56
  • I need await when all observables on the page wuill be completed, should I use forkJoin? –  Apr 25 '20 at 10:03
  • 1
    So, how to complete `_block$` then and `_field$`? –  Apr 25 '20 at 10:08
  • @Jony you can either complete them manually (by calling `complete()`) or use some completable operator. You have to provide more code for us to figure one which option is more appropriate. Anyway, completion does depend upon `_block$` and `_field$` instances. – Zazaeil Apr 25 '20 at 16:43
  • @Jony P.S. Yes, `forkJoin` is the choice if you'd like to run all the observables **in pseudo-parallel** and await for their completeness. In case you rely on unbound stream (i.e., instance that never completes), your `forkJoin` will never complete too. – Zazaeil Apr 25 '20 at 16:46
  • Observable has no `complete()` –  Apr 25 '20 at 17:08
  • @Jony, just a typo, I meant `Observer`. See https://rxjs-dev.firebaseapp.com/guide/observable for examples how to `complete` manually if you'd like to do it in manual fashion. – Zazaeil Apr 25 '20 at 17:37