Skip to content

Why does subject.pipe(op1(), ...) returns an AnonymousSujbect #7337

Answered by voliva
LcsGa asked this question in Q&A
Discussion options

You must be logged in to vote

This is because pipe applies the operators one by one, and those use "lift", which keeps the original constructor intact #60

The only problem is that this can't be easily done with TS, so the type definition for pipe returns an Observable, but it actually returns whatever the original observable type's.

Related #6148 and #7201, quoting Ben Lesh:

The only issue I see is currently RxJS supports the composition of our subject variants through the operator chain, via lift. This is a little known aspect of RxJS that isn't used much, in no smart part because TypeScript can't support it:

const subject = new Subject<number>()

const lifted = subject.pipe(map(n => n + '?'), map(s => s + '!');

li…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LcsGa
Comment options

Answer selected by LcsGa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants