I'm trying to get an Observable to complete in its entirety (meaning the Complete function is called) before the next Observable executes. I've tried many different things, but the closest I've gotten is this:
function() {
observableA.subscribe(
(value) => { },
(err) => { },
() => {
createObservableB();
}
);
return observableB; // ????
}
But I need to return the result from createObservableB() from this function. Again, createObservableB cannot be called until every single value in observableA has been iterated over in its entirety.
Thanks for any help!
You can also try operators like switch or switchmap according to your requirements. Show activity on this post. async main(data: string): string { var process1Data: string = await process1(data). toPromise(); var process2Data: string = process2(process1Data); ... }
forkJoin will wait for all passed observables to emit and complete and then it will emit an array or an object with last values from corresponding observables.
You can use Observables with Promises and with async/await to benefit from the strengths of each of those tools.
takeUntil(end$); When you want to end observable , you do end$. onNext("anything you want here"); . That is in the case the ending event is generated by you.
you can try last
operator
obsA.pipe(last(),mergeMap(()=>obsB)).subscribe()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With