-
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
refactor(Subscription): Get rid of _unsubscribe weirdness #5670
refactor(Subscription): Get rid of _unsubscribe weirdness #5670
Conversation
This is just another step toward getting what we're doing with inheritance to be a little more sane, ultimately, this may be refactored further, as I am not happy with some of these subscribers adding their own teardowns, but this is a start. The goal was to get rid of the weirdness around `_unsubscribe` in our code base. - Moves to calling `_unsubscribe` a new internal name in `Subscription`: `initialTeardown`, because it's slightly more descriptive - Removes `_unsubscribe` usage from the entire codebase. - Formatted a few files just for my sanity.
In retrospect, I might be able to just have a |
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.
One suggestion/question (in multiple places) and one nitpick.
(this as any)._unsubscribe = unsubscribe; | ||
} | ||
} | ||
constructor(private initialTeardown?: () => void) {} |
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.
🎉
@@ -80,6 +80,7 @@ class WindowSubscriber<T> extends SimpleOuterSubscriber<T, any> { | |||
|
|||
constructor(destination: Subscriber<Observable<T>>) { | |||
super(destination); | |||
this.add(this._teardown); |
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.
suggestion: (as above) this.add(this._teardown.bind(this))
?
@@ -90,6 +90,7 @@ class WindowToggleSubscriber<T, O> extends ComplexOuterSubscriber<T, any> { | |||
private openings: Observable<O>, | |||
private closingSelector: (openValue: O) => Observable<any>) { | |||
super(destination); | |||
this.add(this._teardown); |
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.
suggestion: (as above) this.add(this._teardown.bind(this))
?
This is just another step toward getting what we're doing with inheritance to be a little more sane, ultimately, this may be refactored further, as I am not happy with some of these subscribers adding their own teardowns, but this is a start. The goal was to get rid of the weirdness around
_unsubscribe
in our code base._unsubscribe
a new internal name inSubscription
:initialTeardown
, because it's slightly more descriptive_unsubscribe
usage from the entire code base.