samedi 7 mars 2015

emberjs - Add actions to Ember.Service

I'm trying to add actions to an Ember.Service in Ember 1.10 but I've had to alias _actions to the actions hash to get it working, am I missing something?



export default Ember.Service.extend(Ember.ActionHandler, {
actions:{
addItem: function(label) {
console.log(label);
}
},

setup: Ember.on('init', function(){
this._actions = this.actions;
})
});


Looking at the ember source, the triggerEvent method queries the _actions hash:



if (handler._actions && handler._actions[name]) {
if (handler._actions[name].apply(handler, args) === true) {
eventWasHandled = true;
} else {
return;
}
}


I think I am missing something.





Aucun commentaire:

Enregistrer un commentaire