I like to keep my code modular, so I put this kind of code in a separate file (overrides/extra.js
):
import Ember from \'ember\';
Ember.RSVP.con
Yes this is accepted if your module doesn't need to export any data, but there's no need to export anything from a module if it's not required:
import Ember from 'ember';
Ember.RSVP.configure('onerror', function(error) {
....
});
app.js:
import './overrides/extra';
I usually export an initialization function:
I don't know Ember and its initialization but here's how it could look like:
import Ember from 'ember';
export default function initialize(){
return new Promise(function(ok, nok){
try { // or any other kind of failure detection
Ember.RSVP.configure('onerror', function(error) {
ok();
});
... you may do other initializations here
ok();
} catch (e) {
nok(e);
}
});
}
In the calling code
import initEmber from './yourFile.js';
initEmber()
.then(function(){
... here you know Ember is ready
})
.catch(function(){
... damn it!
});
Note that if Ember initialization is synchronous and may not fail, @RGraham answer may suit you better.