lundi 23 novembre 2015

Why does a component class needed to be reopened to specify positional params?

When specifying a positional param for a component class in ember, you have to reopen the class (like below) so it will work, you cannot include it in the initial declaration (at least from what I've seen of examples and my own experience).

import Ember from 'ember';

const component = Ember.Component.extend({ });

component.reopenClass({
  positionalParams: ['post'],
});

export default component;

If you do it in the single declaration (like below) it will not work

import Ember from 'ember';

export default Ember.Component.extend({
  positionalParams: ['post'],
});

Questions

  • Was this something overlooked in the design process? Or was this deliberate (maybe to discourage usage)?
  • Is this because it's a class attribute of some kind? Is there any way to specify class attributes in the class declaration?

It just feels gross that I can't make it part of the same expression and have to assign the class to a variable, reopen it, then finally export it.


Versions

  • ember.js @ 2.2



Aucun commentaire:

Enregistrer un commentaire