All APIs to create custom Subscribers are deprecated or internal #6778
ajafff
started this conversation in
Report issues other than bug
Replies: 1 comment
-
It's definitely on our to-do list to think about a way to "productize" the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Lately I've been writing some custom operators. v7 makes that unreasonably hard (or rather impossible) by deprecating APIs that IMO are needed.
As an example, consider writing a custom
toPromise
similar tofirstValueFrom
, but that never settles the Promise if the Observable doesn't emit a value before completing.Here I need to create a Subscriber up-front because
next
could be called beforesubscribe
returns the Subscription. But now my IDE/linter tells me that the constructor ofSubscriber
is deprecated and considered an internal implementation detail.So what's an appropriate replacement? I tried
SafeSubscriber
, but that is not exported at all.I could copy/re-implement the
Subscriber
class, but I'd prefer not to.Writing custom operators: Let's assume I need to execute some code before AND after
next
is called, e.g. for performance measurements, instrumentation or whatever.Taking inspiration from the v7 operator rewrite, I would write it like this:
Unfortunately
OperatorSubscriber
is not exported from the public API. The discussion in #5836 about exporting it never had a conclusion.So let's go back to the v6 approach of writing custom operators: subclassing
Subscriber
And now I'm back at the start. The construct signature of
Subscriber
is deprecated and will be made internal in v8. So what's the supported way of doing this?I considered using an Observer instead of Subscriber, but that doesn't work well if the consumer unsubscribes while the source is still emitting values synchronously:
Beta Was this translation helpful? Give feedback.
All reactions