Open anilanar opened 2 years ago
I hope the following is not too orthogonal, but it "feels" like chainFirst is a "tap" fn: a fn for side effects in a composition pipeline, that runs the side-effect fn and then returns the value from the previous fn in the pipeline.
Am I way wrong here or what?
🚀 Feature request
Current Behavior
pipe(of('a'), chainFirst(() => EMPTY))
is equivalent toEMPTY
.pipe(of('a'), chainFirst(() => of('b')))
is equivalent toof('a')
.pipe(of('a'), chainFirst(() => from(['b', 'c'])))
is equivalent tofrom(['a', 'a'])
.pipe(of('a'), chainFirst(() => pipe(from(['b', 'c']), chainIOK(a => () => console.log(a)))))
is equivalent tofrom(['a', 'a'])
and printsb c
.Desired Behavior
pipe(of('a'), chainFirst(() => EMPTY))
is equivalent toof(a)
.pipe(of('a'), chainFirst(() => of('b')))
is equivalent toof('a')
.pipe(of('a'), chainFirst(() => from(['b', 'c'])))
is equivalent toof(a)
.pipe(of('a'), chainFirst(() => pipe(from(['b', 'c']), chainIOK(a => () => console.log(a)))))
is equivalent toof('a')
and printsb c
.Suggested Solution
Did anybody else need this ever?
The need for this becomes more apparent for
ObservableEither
, because then errors from the inner observable would be merged into the outer observable.Implementation for
ObservableEither
would be something like this: