In RXJS : replace an infinite observable by an other each time the first emits

139 views Asked by At

I would like to achieve the same thing than below in a smartest way :

charteringsPassFromZeroToOneEmpty$
  .pipe(
    withLatestFrom(transportFeatures$),
    map(
      ([nothing, transportFeatures]: [
        void,
        Partial<TransportFeatures>
      ]) => transportFeatures
    )
  )

Each obervable is made with "valueChange()", in Angular reactive forms. I have tried sample(), throttle() and switchMap(), nothing is working. Does anyone has an idea ?

1

There are 1 answers

1
Naren Murali On

How about combineLatest This is the best I can come up with the details provided.

combineLatest(charteringsPassFromZeroToOneEmpty$, transportFeatures$, firstCharteringWithfirstLoadingLastDelivery$).pipe(
    filter(
      ([nothing, transportFeatures]: [
        void,
        Partial<TransportFeatures>
      ]) => transportFeatures?.multimodal === false
    ),
    map(
      ([nothing, transportFeatures]: [
        void,
        Partial<TransportFeatures>
      ]) => transportFeatures
    ),
    takeUntil(this._onDestroy$)
)