79537852

Date: 2025-03-27 05:04:08
Score: 0.5
Natty:
Report link

does this work for you?

im assuming what u want to achieve was to flatten error result as normal emit, while still able to specify it to retry on error by the consumer

function getFoo$(retry = false) {
    const foo$ = source$.pipe(
        catchError((error) => {
            const optionalPipes = []
            if(retry) optionalPipes.push(mergeMap(() => source$))

            return of({ data: null, error}).pipe(...optionalPipes)
        }),
    )

    return foo$
}
Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: aii-yin