Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deprecated concat operator in RxJS epic

Tags:

rxjs

rxjs6

I have an epic works well with concat operator. Webstorm starts saying it is deprecated in the way I use it. Says

deprecated export function concat<{type: string}[]>( v1: {type: string}[], scheduler: SchedulerLike): Observable> Use scheduled and concatAll (e.g. scheduled([o1, o2, o3], scheduler).pipe(concatAll())

Can't figure out, how to rewrite this code?

const epic = action$ => action$.pipe(
  ofType(TYPE),
  mergeMap(() =>
    concat(
      of({type: 'START'}),
      ajax.getJSON('someurl').pipe(
        mergeMap(serverResponse => ([
          {type: 'LOADED'},
          {type: 'DO_JOB', serverResponse}
        ]))
    )
  )
)
like image 728
acidron Avatar asked Oct 18 '25 16:10

acidron


1 Answers

Use concatWith. concatWith is actually not a completely new operator. It’s only meant to replace the concat operator which is currently marked as deprecated and will be removed in v8.

There’s one subtle difference between the two, though. concatWith only accepts inputs of type ObservableInput, whereas concat can also take a scheduler.

More details can be found here

like image 170
Chris Avatar answered Oct 22 '25 04:10

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!