February 2016
Beginner to intermediate
308 pages
5h 46m
English
Mixins are a great way of reusing and sharing code in Ember. The following recipes go over some basic operations on how to use them in your code.
In this recipe, we'll create a common mixin object.
const common = Ember.Mixin.create({
property1: 'This is a mixin property',
edit: function() {
console.log('Starting to edit');
this.set('isEditing', true);
},
isEditing: false
});This mixin can be added to any object. For the sake of simplicity, all this mixin does is display some text and set the isEditing property to true if the edit function is invoked.
const obj = Ember.Object.extend(common,{ ...Read now
Unlock full access