What’s the recommended way of sending messages from a child controller to a parent controller? I’m currently doing the following:
this.get('parentController').someMethod(param);
This works, but it is fragile as the child controller has knowledge of the parent’s implementation and the parent must implement this method.
I’d like to use Ember.Evented as this would remove the need for the parent to implement a method, it could subscribe to the child events if it wanted to. It seems as though I would need to add a subscription every time a child controller is added though:
childController.on('someEvent', function() {
...
});
Is there a hook provided for every time a new child controller is added? If so, I could use that.
In an ideal world, I would like Ember to provide a facility to bubble events from child controllers up through the hierarchy of descendant controllers, something like:
controller.publish('someEvent', arg1, arg2);
My use case for this is one where I have an ArrayController which contains a number of child ObjectControllers. The ObjectControllers provide a delete method and I’d like to ask the ArrayController to delete our model.