You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The static create methods were a good idea, but they suffer from a couple of issues:
TypeScript has a hard time typing them because of how static inheritance works. For example Subject inherits from Observable and BehaviorSubject inherits from Subject... all of them have (or should have) wildly different signatures for create.
Subject.create doesn't even do what the rest of the create methods do (which is just proxy the constructor), instead it returns an AnonymousSubject, which is really just any old observer "glued" to any old observable to make a subject. So we might want to change that to createSubject or frankenSubject or glueSubject (okay, I'm kidding on the last two) (but the name AnonymousSubject sorta sucks too)
Proposed solution
Create functions that do the same work and export them separately:
import{observable,behaviorSubject,/* et al */}from'rxjs';// usage would beobservable(subscriber=>{subscriber.next('hello world');subscriber.complete();});
The text was updated successfully, but these errors were encountered:
if we're going to away from exposing creation method directly, what makes us prevent just let ppl use class ctor instead of exporting another function for creation?
The static
create
methods were a good idea, but they suffer from a couple of issues:Subject
inherits fromObservable
andBehaviorSubject
inherits fromSubject
... all of them have (or should have) wildly different signatures forcreate
.BehaviorSubject
suffer from bugs like BehaviorSubject created with "create" does not have getValue() method #1890.Subject.create
doesn't even do what the rest of the create methods do (which is just proxy the constructor), instead it returns anAnonymousSubject
, which is really just any old observer "glued" to any old observable to make a subject. So we might want to change that tocreateSubject
orfrankenSubject
orglueSubject
(okay, I'm kidding on the last two) (but the nameAnonymousSubject
sorta sucks too)Proposed solution
Create functions that do the same work and export them separately:
The text was updated successfully, but these errors were encountered: