Merge pull request #26111 from dfreeman/ember-static-initializer-method

[ember] `initializer` and `instanceInitializer` are static methods
This commit is contained in:
Daniel Rosenwasser 2018-05-29 22:12:47 -07:00 committed by GitHub
commit bb1cc0e143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -1075,14 +1075,14 @@ declare module 'ember' {
* after all initializers and therefore after all code is loaded and the app is
* ready.
*/
initializer(initializer: Initializer<Engine>): void;
static initializer(initializer: Initializer<Engine>): void;
/**
* Instance initializers run after all initializers have run. Because
* instance initializers run after the app is fully set up. We have access
* to the store, container, and other items. However, these initializers run
* after code has loaded and are not allowed to defer readiness.
*/
instanceInitializer(instanceInitializer: Initializer<EngineInstance>): void;
static instanceInitializer(instanceInitializer: Initializer<EngineInstance>): void;
/**
* Set this to provide an alternate class to `Ember.DefaultResolver`
*/

View File

@ -1,27 +1,33 @@
import Ember from 'ember';
import { assertType } from "./lib/assert";
let App = Ember.Application.create({
customEvents: {
paste: 'paste'
}
let BaseApp = Ember.Application.extend({
modulePrefix: 'my-app'
});
App.initializer({
BaseApp.initializer({
name: 'my-initializer',
initialize(app) {
app.register('foo:bar', Ember.Object.extend({ foo: 'bar' }));
}
});
App.instanceInitializer({
BaseApp.instanceInitializer({
name: 'my-instance-initializer',
initialize(app) {
app.lookup('foo:bar').get('foo');
}
});
let App2 = Ember.Application.create({
let App1 = BaseApp.create({
rootElement: '#app-one',
customEvents: {
paste: 'paste'
}
});
let App2 = BaseApp.create({
rootElement: '#app-two',
customEvents: {
mouseenter: null,
mouseleave: null