Skip to content
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

fix(rstream): Fix unbound this in method call expression #34

Merged

Conversation

andrew8er
Copy link
Contributor

This PR fixes the reject handler of the Resolver.next() method.

Previously, the expression

(this.fail || this.error)(e)

would call the error method of the prototype if no this.fail was defined, but without binding this to the current object. Thus, the first statement of Subscription.error() would fail with the following error:

TypeError: Cannot set property 'state' of undefined

@postspectacular
Copy link
Member

Thanks @andrew8er! But this would be shorter:

(this.fail || this.error).call(this, e);

@andrew8er
Copy link
Contributor Author

I have not tested this, but I guess an indirect call via call() is both slower and less readable.

@postspectacular
Copy link
Member

It's probably slower, but wouldn't matter much here... anyhow, happy to accept as is if you find the other version less readable... (i don't think it is, but hey... :)

@postspectacular postspectacular merged commit 5afb579 into thi-ng:master Aug 27, 2018
@andrew8er andrew8er deleted the pr/fix-rstream-resolve-errors branch June 3, 2019 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants