-
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): remove to use tryCatch #1389
Conversation
@saneyuki have you compared the performance between master and this branch? I'd be interested to see what sort of difference this makes here. |
I added benchmarks and the following are results (Node 5.7, MacBook Pro (Retina, 15-inch, Mid 2014, 2.8 GHz Intel Core i7, 16 GB 1600 MHz DDR3)): Before
After to remove
|
@@ -126,4 +126,24 @@ export class UnsubscriptionError extends Error { | |||
super('unsubscriptoin error(s)'); | |||
this.name = 'UnsubscriptionError'; | |||
} | |||
} | |||
|
|||
function callPrivateUnsubscribe(sub: Subscription): [boolean, any] { |
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.
These external functions are going to introduce closure when they're used. If they were on the Subscription prototype, they would not.
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.
These external functions are going to introduce closure when they're used
This callPrivateUnsubscribe
don't capture a variables in outer environments. This would not be a closure which capture an environment. What would be a problem?
I tried add To add So I propose that we concentrate to "remove How about do you think? |
This reverts commit 58817feaa485a976c1f6fa7a3f88213c22298c2e.
if (_unsubscribe) { | ||
// Check `_unsubscribe`to avoid override `this._unsubscribe` accidentally. | ||
// Dn't call `super(_unsubscribe)` from a derived class. | ||
if (!!_unsubscribe) { |
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.
If you're asserting "truthiness" here, you can just do it, no need for the !!
. If you truly need a boolean, then Boolean(x)
is probably more efficient than two operators back to back (but I'm speculating)
Left a few more comments. This needs rebased again. Sorry for the slowness with the merge, but Subscription is one area we have to get right. |
This seems to have died out. I'm going to close it for now, because I think that the code has diverged significantly since this PR was made. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Subscription
and separate an interface fromSubscription
class...