The purpose of this document is to demonstrate how methods and classes could be import
ed inside an Ember CLI project, instead of accessing them on the Ember
namespace.
For example, instead of doing this:
import Ember from 'ember';
export default Ember.Component.extend({
gravatarUrl: Ember.computed('email', 'size', function() {})
});
We could import
all the methods and classes we need in that particular file:
import Component from 'ember/component';
import computed from 'ember/computed';
export default Component.extend({
gravatarUrl: computed('email', 'size', function() {})
});
Because at the end of the day, many developers are already doing something resembling to this:
import Ember from 'ember';
const { Component, computed } = Ember;
The upside is that module error messages are much better than TypeError: undefined is not a function
. Not found module errors are also detected at compile-time, which is a nice additional safety net.
And since Ember is apparently moving away from prototype extensions, the usage of computed
, string functions, etc will only rise in the future.