EmberJS reopen Classes and Instances

This is only refreshing the class execution without rethinking it and reviving the class by indicating new properties in it. This is conceivable by utilizing the accompanying strategies −

  • reopen() − It adds properties and strategies to instances.

  • reopenClass() − It adds properties and strategies to the classes..


The following precedent uses the strategies referenced above and determines the new properties or techniques in it −

import Ember from 'ember'; 

export default function() { 

//revive() technique for instances 

var Person = Ember.Object.extend ({ 

firstName: null, 

lastName: null, 


//adding new factor to the Person class 

Person.reopen ({ 

middleName: 'Rock', 


document.write('Middle Name: '+Person.create().get('middleName')); 


//reopenClass() strategy for classes 

Person.reopenClass ({ 

//making new capacity for class Person 

openClass: function() { 

return Person.create({isMan: true}); 



document.write('isMan: '+Person.openClass().get('isMan')); 


Now open the app.js document and include the accompanying line at the highest point of the record −

import reopenclass from './reopenclass'; 

Where, reopenclass is a name of the document determined as "reopenclass.js" and made under the "application" folder.

Next call the acquired "reopenclass" at the base, before the fare. It executes the reopenclass work which is made in the reopenclass.js document −