Skip to content

Commit 41e2f80

Browse files
jolisskrisselden
authored andcommitted
Extract runInjections from Application#initialize
This also runs the injections on the newly created router property, because we collect the keys after adding the router. But this shouldn't do any harm.
1 parent 20cab07 commit 41e2f80

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

packages/ember-application/lib/system/application.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,6 @@ Ember.Application = Ember.Namespace.extend(
315315
@param router {Ember.Router}
316316
*/
317317
initialize: function(router) {
318-
var injections = get(this.constructor, 'injections'),
319-
namespace = this;
320-
321318
if (!router && Ember.Router.detect(this.Router)) {
322319
router = this.Router.create();
323320
this._createdRouter = router;
@@ -335,7 +332,24 @@ Ember.Application = Ember.Namespace.extend(
335332
set(router, 'namespace', this);
336333
}
337334

338-
var graph = new Ember.DAG(), i, injection;
335+
this.runInjections(router);
336+
337+
Ember.runLoadHooks('application', this);
338+
339+
// At this point, any injections or load hooks that would have wanted
340+
// to defer readiness have fired.
341+
this.advanceReadiness();
342+
343+
return this;
344+
},
345+
346+
/** @private */
347+
runInjections: function(router) {
348+
var injections = get(this.constructor, 'injections'),
349+
graph = new Ember.DAG(),
350+
namespace = this,
351+
properties, i, injection;
352+
339353
for (i=0; i<injections.length; i++) {
340354
injection = injections[i];
341355
graph.addEdges(injection.name, injection.injection, injection.before, injection.after);
@@ -347,14 +361,6 @@ Ember.Application = Ember.Namespace.extend(
347361
injection(namespace, router, property);
348362
});
349363
});
350-
351-
Ember.runLoadHooks('application', this);
352-
353-
// At this point, any injections or load hooks that would have wanted
354-
// to defer readiness have fired.
355-
this.advanceReadiness();
356-
357-
return this;
358364
},
359365

360366
didBecomeReady: function() {

0 commit comments

Comments
 (0)