Skip to content

Commit 9e7b80b

Browse files
Merge pull request #21056 from emberjs/nvp/remove-application-lazy-load
Remove '@ember/application's lazy load / onLoad stuff (private API)
2 parents 0673aaf + 97812c1 commit 9e7b80b

File tree

10 files changed

+1
-205
lines changed

10 files changed

+1
-205
lines changed

index.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@
1515
// Test under octane defaults
1616
EmberENV._DEFAULT_ASYNC_OBSERVERS = true;
1717

18-
// Test for "hooks in EmberENV.EMBER_LOAD_HOOKS['hookName'] get executed"
19-
EmberENV.EMBER_LOAD_HOOKS = EmberENV.EMBER_LOAD_HOOKS || {};
20-
EmberENV.EMBER_LOAD_HOOKS.__before_ember_test_hook__ =
21-
EmberENV.EMBER_LOAD_HOOKS.__before_ember_test_hook__ || [];
22-
EmberENV.__test_hook_count__ = 0;
23-
EmberENV.EMBER_LOAD_HOOKS.__before_ember_test_hook__.push(function (object) {
24-
EmberENV.__test_hook_count__ += object;
25-
});
26-
2718
// Handle testing feature flags
2819
if (QUnit.urlParams.ENABLE_OPTIONAL_FEATURES) {
2920
EmberENV.ENABLE_OPTIONAL_FEATURES = true;

lib/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ const shim = addonV1Shim(path.join(__dirname, '..'), {
5454
'./dist/dev/packages/@ember/-internals/views/lib/views/states.js',
5555
'./dist/dev/packages/@ember/application/index.js',
5656
'./dist/dev/packages/@ember/application/instance.js',
57-
'./dist/dev/packages/@ember/application/lib/lazy_load.js',
5857
'./dist/dev/packages/@ember/application/namespace.js',
5958
'./dist/dev/packages/@ember/array/-internals.js',
6059
'./dist/dev/packages/@ember/array/index.js',

packages/@ember/-internals/environment/lib/env.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ export const ENV = {
144144
*/
145145
_RERENDER_LOOP_LIMIT: 1000,
146146

147-
EMBER_LOAD_HOOKS: {} as {
148-
[hook: string]: Function[];
149-
},
150-
151147
FEATURES: {} as {
152148
[feature: string]: boolean;
153149
},
@@ -179,18 +175,6 @@ if (typeof EmberENV === 'object' && EmberENV !== null) {
179175
}
180176
}
181177

182-
// TODO this does not seem to be used by anything,
183-
// can we remove it? do we need to deprecate it?
184-
let { EMBER_LOAD_HOOKS } = EmberENV;
185-
if (typeof EMBER_LOAD_HOOKS === 'object' && EMBER_LOAD_HOOKS !== null) {
186-
for (let hookName in EMBER_LOAD_HOOKS) {
187-
if (!Object.prototype.hasOwnProperty.call(EMBER_LOAD_HOOKS, hookName)) continue;
188-
let hooks = EMBER_LOAD_HOOKS[hookName];
189-
if (Array.isArray(hooks)) {
190-
ENV.EMBER_LOAD_HOOKS[hookName] = hooks.filter((hook) => typeof hook === 'function');
191-
}
192-
}
193-
}
194178
let { FEATURES } = EmberENV;
195179
if (typeof FEATURES === 'object' && FEATURES !== null) {
196180
for (let feature in FEATURES) {

packages/@ember/application/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { assert } from '@ember/debug';
1010
import { DEBUG } from '@glimmer/env';
1111
import { join, once, run, schedule } from '@ember/runloop';
1212
import { libraries } from '@ember/-internals/metal';
13-
import { _loaded, onLoad, runLoadHooks } from './lib/lazy_load';
1413
import { RSVP } from '@ember/-internals/runtime';
1514
import { EventDispatcher } from '@ember/-internals/views';
1615
import Route from '@ember/routing/route';
@@ -711,7 +710,6 @@ class Application extends Engine {
711710

712711
try {
713712
this.runInitializers();
714-
runLoadHooks('application', this);
715713
this.advanceReadiness();
716714
// Continues to `didBecomeReady`
717715
} catch (error) {
@@ -883,10 +881,6 @@ class Application extends Engine {
883881
willDestroy() {
884882
super.willDestroy();
885883

886-
if (_loaded['application'] === this) {
887-
_loaded['application'] = undefined;
888-
}
889-
890884
if (this._applicationInstances.size) {
891885
this._applicationInstances.forEach((i) => i.destroy());
892886
this._applicationInstances.clear();
@@ -1137,4 +1131,4 @@ function commonSetupRegistry(registry: Registry) {
11371131
registry.register('service:router', RouterService);
11381132
}
11391133

1140-
export { Application as default, _loaded, onLoad, runLoadHooks };
1134+
export { Application as default };

packages/@ember/application/lib/lazy_load.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

packages/@ember/application/tests/application_test.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { getDebugFunction, setDebugFunction } from '@ember/debug';
66
import EmberRoute from '@ember/routing/route';
77
import Router from '@ember/routing/router';
88
import NoneLocation from '@ember/routing/none-location';
9-
import { _loaded } from '@ember/application';
109
import Controller from '@ember/controller';
1110
import EmberObject from '@ember/object';
1211
import {
@@ -298,14 +297,6 @@ moduleFor(
298297
);
299298
}
300299

301-
[`@test does not leak itself in onLoad._loaded`](assert) {
302-
assert.equal(_loaded.application, undefined);
303-
runTask(() => this.createApplication());
304-
assert.equal(_loaded.application, this.application);
305-
runTask(() => this.application.destroy());
306-
assert.equal(_loaded.application, undefined);
307-
}
308-
309300
[`@test can build a registry via Application.buildRegistry() --- simulates ember-test-helpers`](
310301
assert
311302
) {

packages/@ember/application/tests/lazy_load_test.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

packages/ember/barrel.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ import EmberArrayProxy from '@ember/array/proxy';
7979
import EmberApplication, {
8080
getOwner as applicationGetOwner,
8181
setOwner as applicationSetOwner,
82-
onLoad as applicationOnLoad,
83-
runLoadHooks as applicationRunLoadHooks,
8482
} from '@ember/application';
8583
import EmberApplicationInstance from '@ember/application/instance';
8684
import EmberNamespace from '@ember/application/namespace';
@@ -207,8 +205,6 @@ namespace Ember {
207205

208206
// ****@ember/application****
209207
export const getOwner = applicationGetOwner;
210-
export const onLoad = applicationOnLoad;
211-
export const runLoadHooks = applicationRunLoadHooks;
212208
export const setOwner = applicationSetOwner;
213209
export const Application = EmberApplication;
214210
export type Application = EmberApplication;
@@ -657,8 +653,6 @@ Object.defineProperty(Ember, 'testing', {
657653
enumerable: false,
658654
});
659655

660-
applicationRunLoadHooks('Ember.Application', EmberApplication);
661-
662656
let EmberHandlebars: EmberHandlebars = {
663657
template,
664658
Utils: {},
@@ -727,7 +721,4 @@ function defineEmberTestingLazyLoad(key: 'Test') {
727721

728722
defineEmberTestingLazyLoad('Test');
729723

730-
// @ts-expect-error Per types, runLoadHooks requires a second parameter. Should we loosen types?
731-
applicationRunLoadHooks('Ember');
732-
733724
export default Ember;

packages/ember/tests/reexports_test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ import { DEPRECATIONS } from '@ember/-internals/deprecations';
120120
let allExports = [
121121
['Application', '@ember/application', 'default', test0],
122122
['getOwner', '@ember/application', 'getOwner', test0],
123-
['onLoad', '@ember/application', 'onLoad', test0],
124-
['runLoadHooks', '@ember/application', 'runLoadHooks', test0],
125123
['setOwner', '@ember/application', 'setOwner', test0],
126124
['ApplicationInstance', '@ember/application/instance', 'default', test1],
127125
['Namespace', '@ember/application/namespace', 'default', test2],

tests/docs/expected.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ module.exports = {
352352
'once',
353353
'one',
354354
'oneWay',
355-
'onLoad',
356355
'onUpdateURL',
357356
'options',
358357
'optionsForType',
@@ -438,7 +437,6 @@ module.exports = {
438437
'runInDebug',
439438
'runInitializers',
440439
'runInstanceInitializers',
441-
'runLoadHooks',
442440
'schedule',
443441
'scheduleOnce',
444442
'send',

0 commit comments

Comments
 (0)