Skip to content

Instantly share code, notes, and snippets.

@pzuraq
Last active January 18, 2018 19:32
Show Gist options
  • Select an option

  • Save pzuraq/775adf45deae5bf68dbc34ac15ca8387 to your computer and use it in GitHub Desktop.

Select an option

Save pzuraq/775adf45deae5bf68dbc34ac15ca8387 to your computer and use it in GitHub Desktop.
ES Class Todos

Ember ES Class Todos

  • Update constructor to receive arguments directly
    • Implemented in this PR, just needs review and merge
    • Probably could be simplified in Ember 3, we can remove multi-object create
  • Update concatenated and merged properties in RFC
    • Concatenated and merged properties will not be able to work the way they used to.
    • No way to know the value of a field before an instance is created
    • Parent class constructor finishes before child constructor, so no way to get value in makeCtor base constructor
  • Fix native getters/setters (make mandatory setter aware of them)
    • applyMixin , watchKey, and defineProperty erase native getters and setters
    • watchKey and defineProperty only erase them in development mode, when adding mandatory setter
    • Normally not a problem because applyMixin gets rid of them anyways, but can't do this for ES classes
    • Could cause heisenbugs, difficult to track because must observe to change behavior, and won't change at all in production
  • Fix proto
    • Currently proto gets called once per makeCtor base constructor
    • Does not get called for new classes because wasApplied is a closure var - needs to be moved to meta for the class
    • proto collapsing needs to be made aware of the prototype chain, not just mixins for the class
  • Fix constructor chain
    • this._super() and super appear to work just fine in normal methods
    • when doing .extend() native class constructors never called
    • makeCtor constructor doesn't call super, but probably can be made to conditionally
    • What should the execution order of the following be?
let Foo = Ember.Object.extend({
  init() {
    this._super(...arguments);
    console.log('Foo'); 
  }
});

class Bar extends Foo {
  constructor() {
    super(...arguments);
    console.log('Bar');
  }
}

let Baz = Bar.extend({
  init() {
    this._super(...arguments);
    console.log('Baz');
  }
});

Baz.create();

// Foo - init
// Baz - init
// Bar - constructor

// OR

// Foo - init
// Bar - constructor
// Baz - init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment