-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
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
Subjectinherits fromObservableandBehaviorSubjectinherits fromSubject... all of them have (or should have) wildly different signatures forcreate. - Because of how inheritance works, poorly implemented subclasses (like
BehaviorSubjectsuffer from bugs like BehaviorSubject created with "create" does not have getValue() method #1890. Subject.createdoesn'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 tocreateSubjectorfrankenSubjectorglueSubject(okay, I'm kidding on the last two) (but the nameAnonymousSubjectsorta sucks too)
Proposed solution
Create functions that do the same work and export them separately:
import { observable, behaviorSubject, /* et al */ } from 'rxjs';
// usage would be
observable(subscriber => {
subscriber.next('hello world');
subscriber.complete();
});MattDiMu
Metadata
Metadata
Assignees
Labels
No labels