Reopen in Ember 2.11


#1

I have the following code in an Ember 1 app:

MyAPP.reopen({
  ready: function() {
    this._super();
    var ChapterView = this.__container__.lookupFactory("view:course/left-nav-chapter");
    ChapterView.reopen( {
      toggle: function() {
        this._super();
        var expanded = this.get("expanded");
        if(expanded) {
          // do something
        } 
      }
    });
  }
});

This code is wrapped in a script tag in a HTML page that contains the Ember application. I’m reopening my main app in order to change the toggle function from a particular element.

I’m trying to adapt this to an Ember 2 application:

MyAPP2.reopen({
  ready: function() {
    this._super();
    console.log('ready?')
  }
});

It seems that the ready function is never triggered. I looked the docs and it seems that reopen is still something valid, but not sure if this is a Ember 2 thing.

Any thoughts here?

Thanks in advance


#2

Several things would have changed between 1.x and 2.11.

  1. Views are no more, they don’t exist/work as of 2.4
  2. The lookup stuff has changed
  3. And initializers would be better over ready()