Corvus27
Corvus27

Reputation: 1

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

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 ?

Upvotes: 0

Views: 174

Answers (1)

Naren Murali
Naren Murali

Reputation: 56650

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$)
)

Upvotes: 0

Related Questions