Last active
April 7, 2017 01:35
-
-
Save ef4/016664960593c9884b04 to your computer and use it in GitHub Desktop.
Yielding Actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
// Nothing special here, just a familiar action handler. | |
actions: { | |
submit: function(msg) { | |
alert("yay " + msg); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
// This is a helper that lets you package up an action | |
// from the current context so you can pass it elsewhere. | |
// The Ember 2.0 RFC says that {{action "foo"}} will | |
// work this way, but in 1.0 it has a different meaning, so I | |
// named this one `make-action` instead. | |
export function makeAction(params) { | |
var actionName = params[0]; | |
return (...args) => { | |
this.send(actionName, ...args); | |
}; | |
} | |
export default Ember.HTMLBars.makeBoundHelper(makeAction); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can I have your options on my comment here? emberjs/ember.js#4985 (comment)
I think this gist is old, and probably there should be a better way of doing it. Thanks for reviewing.