-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Subject.create, refactor WebSocketSubject #7381
Remove Subject.create, refactor WebSocketSubject #7381
Conversation
BREAKING CHANGE: Removed the deprecated `Subject.create` method. If you need to create an object that is "half Observable, half Observer", you'll need to either bolt `next`, `error`, and `complete` handlers onto an `Observable` and property type the return... or you'll need to create your own class that is backed by an `Observable`. In any case, if the `Observer` and the `Observable` are so unrelated that you have to bolt them together, you're probably better off with those two objects separately. This is why `Subject.create` has been deprecated for so long.
…input` and `output`.
BREAKING CHANGE: `WebSocketSubject` is no longer `instanceof Subject`. Check for `instanceof WebSocketSubject` instead.
private _inputBuffer: In[] = []; | ||
|
||
private _hasError = false; | ||
|
||
private _error: any; | ||
|
||
private _isComplete = false; | ||
|
||
private _subscriberCounter = 0; | ||
|
||
private _subscribers = new Map<number, Subscriber<Out>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be real private fields without the ugly _
prefix instead of TS private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I think overall, RxJS is due for an overhaul in this area. The upside is we can't accidentally publicly expose any #private
properties. The downside is you can't destructure them. Which is mostly a superficial downside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benlesh, I might try to do this.
Thank you for the review @ssilve1989! ❤️ |
// Setting this here because a previous version of this allowed | ||
// WebSocket to be polyfilled later than DEFAULT_WEBSOCKET_CONFIG | ||
// was defined. | ||
WebSocketCtor: WebSocket, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this throw an exception if the WebSocket
is not available globally?
WebSocketCtor
becomes almost useless.
An incremental refactor of
WebSocketSubject
to clean it up quite a bit. best reviewed per commitAdds long-awaited type fix. WebSocketSubject can now take two type parameters that allow it to accept a different input type than it outputs:
Includes the following BREAKING CHANGES:
WebSocketSubject
is no longerinstanceof Subject
. It really didn't make any sense to do this, it didn't leverage anything fromSubject
to begin with.Subject.create
, a long-deprecated API has been removed. If you recall,Subject.create(observer, observable)
basically "glued" the observer to the observable.This removes
AnonymousSubject
, which was never exported, and was overall weird.