vendredi 6 février 2015

Ember Mixins and the needs property

I have sort of a general question on how the controller needs property works with regard to mixins


Lets say I have a shopping card model that resides in the application controller so it's available everywhere in the app



// application route
export default Ember.Route.extend({
setupController: function(controller, model) {
this._super(controller, model);
controller.set('cart', this.store.createRecord('cart'));
}
});


Now any other controller that needs to use the cart, I want to provide a mixin:



// mixins/cart-access
export default Ember.Mixin.create({
needs: ['application'];
cart: Ember.computed.alias('controllers.application.cart')
});

// some controller
export default Ember.Controller.extend(CartAccess, {});


This is all well and good, but will it cause problems if in another controller I set the needs property to something else?



// some other controller
export default Ember.Controller.extend(CartAccess, {
needs: ['some-other-controller'] // not inlcuding application
});




Aucun commentaire:

Enregistrer un commentaire