Ember Bind Helper
This addon provides a bind helper to bind a function to a context.
Installation
If you are running Ember 3.4+, just ember install ember-bind-helper.
If you are running a version older than 3.4, do ember install ember-bind-helper@0.3.2 instead.
Using bind
Let's say we want to call a method of an object when we click a function. We might think of doing the following:
Sadly, this might not work as expected, given that the context would be the
controller
(twiddle).
To solve this, you can use the bind helper:
This automagically sets the context to myObject. If the method were myObject.mySubobject.myMethod it would
bind it to myObject.mySubobject and so on. The only exception to this rule is that if the last part of the chain
before the method name is actions, it gets removed too:
This sets the context to myObject. Normally it would have been myObject.actions but, given the last part is actions,
ember-bind-helper removes that too leaving only myObject.
You can explicitly set the target by adding a named argument target:
bind also passes any extra parameters to the binding function. Thus, when we click this button:
myMethod will receive 1, 2, 3 and "caramba" as arguments.
Linting
npm run lint:hbsnpm run lint:jsnpm run lint:js -- --fix
License
This project is licensed under the MIT License.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
