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

Remove binding in Stateful#observe() and Destroyable#own() #66

Open
wkeese opened this issue Jul 9, 2020 · 0 comments
Open

Remove binding in Stateful#observe() and Destroyable#own() #66

wkeese opened this issue Jul 9, 2020 · 0 comments

Comments

@wkeese
Copy link
Member

wkeese commented Jul 9, 2020

Stateful#observe() and Destroyable#own() automatically bind the callback to this... which was a nice feature until ES6 came along.

Now, code like this has unexpected results:

const MyClass = dcl (null, {
    myWidget: ...,

    myMethod: function () {
         this.myWidget.observe(props => console.log(this));
    }
}
```

In the above code it's natural to assume that the `console.log(this)` will print`MyClass`, but it actually refers to `myWidget`,
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

No branches or pull requests

1 participant