How can you simplify your code?

  • 0
    observable$.subscribe(result => {
        mergeMap(x => {...}),
        catchError(err => throwError(err))

    New events on click arrive in observable $, which generate the result object. Inside mergeMap, the logic of requests to the server with data from result. Each such request needs to be handled with errors.
    How can you get rid of nested subscribes?
    JavaScript Anonymous, Mar 27, 2019

  • 1 Answers
  • 0
    use switchMap

    switchMap((result) => {
    return of(result).pipe(.....)

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!