Dereferencing/Destructuring Ember Global... Best Practice?

In regards to preparing for a world without the Ember global, which would be considered “the right way” to do this?

import Ember from 'ember';
const { computed } = Ember;
const { alias, reads } = Computed

export default Ember.Component.extend({
  prop1: alias('some.thing'),
  prop2: reads('other.thing'),
  prop3: computed('coolbeans', function() { ... 

Or

import Ember from 'ember';
const { computed } = Ember;

export default Ember.Component.extend({
  prop1: computed.alias('some.thing'),
  prop2: computed.reads('other.thing'),
  prop3: computed('coolbeans', function() { ... 

(The difference is using computed.alias, computed.reads vs destructuring all the way down to alias and reads).

Thanks! Adam

I don’t think its a big deal either way… but my preference is for the first method.

import Ember from 'ember';
const { computed: { alias, reads } } = Ember;

or

import { alias, reads }  from 'ember-computed';

I believe the latter might be being recommended against at the moment, as ember’s module interface is not finalised yet, but it won’t exactly be complex to upgrade from

Awesome - thanks guys.

This is what’s coming rfcs/0176-javascript-module-api.md at master · emberjs/rfcs · GitHub

1 Like