Hello, I have a specific goal in mind with rxjs, but I am facing some challenges trying to achieve it within certain parameters.
Here is what I aim to accomplish:
first$ ---x|
second$ ------x|
subscribe -----------x|
However, this is the current outcome:
first$ ---x|
second$ ------x|
subscribe ---x------x
This is the code snippet I am working with:
const checkFirstSide$: Observable<boolean> = this.checkSide('first');
const checkOtherSide$: Observable<boolean> = this.checkSide('other');
concat(
checkFirstSide$,
checkOtherSide$
).pipe(
timeout(15000)
).subscribe({
next: (success) => {
doSomething(success);
},
error: (error) => {
handleError(error);
},
complete: () => {
doSomethingOnComplete();
}
});
The specific constraints are as follows:
- Subscriptions need to occur sequentially
- Each subscription should only proceed if the previous one was successful (no errors)
- All actions must time out after 15 seconds
- In case of an error, execution should halt (triggering handleError and completing)
- The observer's
next
function should execute once, followed bycomplete