I'm using angular and rxJS
I'm pretty new to rxJS
operators and can't find a way to keep everything inside a stream.
My stream is pretty long so I'll get straigth to the point explaining the problem I'm dealing with
I need to run parralel Observables
that can be triggered multiple times and process their data in the same manner, but their subscription needs to be in a certain order. for example
firstObservable$.pipe(
map(() => secondObservable$),//this will only be triggered once
tap(value => doSomething(value)),//data is processed once following the stream
mergeMap(() => ThirdObservable$),//this one will be triggered multiple times but is subscribed in a particular order
tap(value => doAnotherThing(value)),//how can I attach the processing og data to the observable?
mergeMap(() => FourthObservable$),//this one will be triggered multiple times but is subscribed in a particular order
tap(value => andAnother(value)),//how can I attach the processing og data to the observable?
map(() => FifthObservable$),//this will only be triggered once
tap(value => again(value))//data is processed once following the stream
).subscribe()
now my problem is that if ThirdObservable$
is triggered as second time it will continue the rest of the stream and call FourthObservable$
and FifthObservable$
I would like the equivalent of
firtsObservable$.subscribe( // triggered Once
(value) => secondObservable$.subscribe( // triggered Once
(secondValue) => {
processSecondValueOnce(secondValue)
ThirdObservable$.subscribe(thirdValue => process(thirdValue)) // this can be triggered multiple times
fourthObservable$.subscribe(fourthValue => process(fourthValue)) // this can be triggered multiple times
fifthObservable$.subscribe( // triggered Once
(fifthValue) => {
process(fifthValue)
}
)
}
)
)