Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Latest commit

 

History

History
38 lines (26 loc) · 783 Bytes

set_in_init.md

File metadata and controls

38 lines (26 loc) · 783 Bytes

In Ember 0.9, calling set during init will

  1. set the property
  2. notify all observers and dependent properties

In Ember 1, it only does the first. That is, objects are in a "silent" mode during init.

Transition

Ember 1 provides an .on('init') hook that runs just after init finishes. It is the recommended way of providing additional initialization behavior.

If you have code that looks like

var MyObject = Ember.Object.extend({
  
  init: function() {
    var result = this._super();
    this.set('someArray', []);
  }

});

and you expect any dependencies of someArray to be notified, you should change it to

var MyObject = Ember.Object.extend({
  
  initializeSomeArray: function() {
    this.set('someArray', []);
  }.on('init')

});