8000 Remove binding in Stateful#observe() and Destroyable#own() · Issue #66 · ibm-js/decor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Remove binding in Stateful#observe() and Destroyable#own() #66
Open
@wkeese

Description

@wkeese

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`,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0