ember-source 4.2.0-beta.1 → 4.3.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blueprints/component-addon/index.js +2 -3
- package/blueprints/component-class-addon/index.js +2 -3
- package/blueprints/controller/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/controller/index.js +2 -4
- package/blueprints/route/files/__root__/__path__/__name__.js +3 -3
- package/blueprints/route/index.js +2 -3
- package/blueprints/service/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/service/index.js +2 -4
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +1238 -852
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +88 -56
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3211 -2123
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/header/loader.js +0 -1
- package/dist/packages/@ember/-internals/bootstrap/index.js +0 -2
- package/dist/packages/@ember/-internals/container/index.js +2 -1
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +3 -3
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +52 -52
- package/dist/packages/@ember/-internals/glimmer/index.js +101 -80
- package/dist/packages/@ember/-internals/meta/lib/meta.js +59 -2
- package/dist/packages/@ember/-internals/metal/index.js +51 -76
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +14 -4
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +7 -49
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +57 -33
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +22 -7
- package/dist/packages/@ember/-internals/routing/lib/utils.js +23 -11
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -32
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -0
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +16 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +48 -48
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
- package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +1 -2
- package/dist/packages/@ember/-internals/runtime/lib/type-of.js +1 -1
- package/dist/packages/@ember/-internals/utils/index.js +9 -9
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -4
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -0
- package/dist/packages/@ember/application/lib/application.js +0 -2
- package/dist/packages/@ember/array/index.js +1 -1
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/deprecate.js +12 -10
- package/dist/packages/@ember/object/compat.js +16 -7
- package/dist/packages/@ember/polyfills/lib/assign.js +1 -0
- package/dist/packages/@ember/runloop/index.js +9 -9
- package/dist/packages/@ember/string/index.js +1 -0
- package/dist/packages/ember/index.js +1 -2
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +1362 -681
- package/package.json +31 -31
- package/blueprints/component-addon/native-files/__root__/__path__/__name__.js +0 -1
- package/blueprints/component-class-addon/native-files/__root__/__path__/__name__.js +0 -1
- package/blueprints/controller/native-files/__root__/__path__/__name__.js +0 -4
- package/blueprints/edition-detector.js +0 -13
- package/blueprints/route/native-files/__root__/__path__/__name__.js +0 -11
- package/blueprints/route/native-files/__root__/__templatepath__/__templatename__.hbs +0 -2
- package/blueprints/service/native-files/__root__/__path__/__name__.js +0 -4
|
@@ -80,7 +80,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
80
80
|
this.currentRouteName = null;
|
|
81
81
|
this.currentPath = null;
|
|
82
82
|
this.currentRoute = null;
|
|
83
|
-
this._qpCache = Object.create(null);
|
|
83
|
+
this._qpCache = Object.create(null); // Set of QueryParam['urlKey']
|
|
84
|
+
|
|
84
85
|
this._qpUpdates = new Set();
|
|
85
86
|
this._queuedQPChanges = {};
|
|
86
87
|
this._toplevelView = null;
|
|
@@ -186,7 +187,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
186
187
|
_initRouterJs() {
|
|
187
188
|
let location = get(this, 'location');
|
|
188
189
|
let router = this;
|
|
189
|
-
|
|
190
|
+
const owner = getOwner(this);
|
|
191
|
+
assert('Router is unexpectedly missing an owner', owner);
|
|
190
192
|
let seen = Object.create(null);
|
|
191
193
|
|
|
192
194
|
class PrivateRouter extends Router {
|
|
@@ -203,6 +205,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
let fullRouteName = `route:${routeName}`;
|
|
208
|
+
assert('Route is unexpectedly missing an owner', routeOwner);
|
|
206
209
|
let route = routeOwner.lookup(fullRouteName);
|
|
207
210
|
|
|
208
211
|
if (seen[name]) {
|
|
@@ -367,7 +370,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
367
370
|
let enableLoadingSubstates = this._hasModuleBasedResolver();
|
|
368
371
|
|
|
369
372
|
let router = this;
|
|
370
|
-
|
|
373
|
+
const owner = getOwner(this);
|
|
374
|
+
assert('Router is unexpectedly missing an owner', owner);
|
|
371
375
|
let options = {
|
|
372
376
|
enableLoadingSubstates,
|
|
373
377
|
|
|
@@ -397,6 +401,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
397
401
|
|
|
398
402
|
_hasModuleBasedResolver() {
|
|
399
403
|
let owner = getOwner(this);
|
|
404
|
+
assert('Router is unexpectedly missing an owner', owner);
|
|
400
405
|
let resolver = get(owner, 'application.__registry__.resolver.moduleBasedResolver');
|
|
401
406
|
return Boolean(resolver);
|
|
402
407
|
}
|
|
@@ -503,6 +508,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
503
508
|
|
|
504
509
|
if (!this._toplevelView) {
|
|
505
510
|
let owner = getOwner(this);
|
|
511
|
+
assert('Router is unexpectedly missing an owner', owner);
|
|
506
512
|
let OutletView = owner.factoryFor('view:-outlet');
|
|
507
513
|
let application = owner.lookup('application:main');
|
|
508
514
|
let environment = owner.lookup('-environment:main');
|
|
@@ -580,8 +586,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
580
586
|
let infos = this._routerMicrolib.currentRouteInfos;
|
|
581
587
|
|
|
582
588
|
if (this.namespace.LOG_TRANSITIONS) {
|
|
583
|
-
// eslint-disable-next-line no-console
|
|
584
|
-
|
|
589
|
+
assert('expected infos to be set', infos); // eslint-disable-next-line no-console
|
|
590
|
+
|
|
585
591
|
console.log(`Intermediate-transitioned into '${EmberRouter._routePath(infos)}'`);
|
|
586
592
|
}
|
|
587
593
|
}
|
|
@@ -686,7 +692,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
686
692
|
_activeQPChanged(queryParameterName, newValue) {
|
|
687
693
|
this._queuedQPChanges[queryParameterName] = newValue;
|
|
688
694
|
once(this, this._fireQueryParamTransition);
|
|
689
|
-
}
|
|
695
|
+
} // The queryParameterName is QueryParam['urlKey']
|
|
696
|
+
|
|
690
697
|
|
|
691
698
|
_updatingQPChanged(queryParameterName) {
|
|
692
699
|
this._qpUpdates.add(queryParameterName);
|
|
@@ -718,6 +725,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
718
725
|
let location = this.location;
|
|
719
726
|
let rootURL = this.rootURL;
|
|
720
727
|
let owner = getOwner(this);
|
|
728
|
+
assert('Router is unexpectedly missing an owner', owner);
|
|
721
729
|
|
|
722
730
|
if ('string' === typeof location) {
|
|
723
731
|
let resolvedLocation = owner.lookup(`location:${location}`);
|
|
@@ -729,6 +737,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
729
737
|
url: 'https://emberjs.com/deprecations/v4.x#toc_deprecate-auto-location',
|
|
730
738
|
for: 'ember-source',
|
|
731
739
|
since: {
|
|
740
|
+
available: '4.1.0',
|
|
732
741
|
enabled: '4.1.0'
|
|
733
742
|
}
|
|
734
743
|
});
|
|
@@ -761,6 +770,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
761
770
|
url: 'https://emberjs.com/deprecations/v4.x#toc_deprecate-auto-location',
|
|
762
771
|
for: 'ember-source',
|
|
763
772
|
since: {
|
|
773
|
+
available: '4.1.0',
|
|
764
774
|
enabled: '4.1.0'
|
|
765
775
|
}
|
|
766
776
|
});
|
|
@@ -1187,6 +1197,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
1187
1197
|
|
|
1188
1198
|
if (!engineInstance) {
|
|
1189
1199
|
let owner = getOwner(this);
|
|
1200
|
+
assert('Router is unexpectedly missing an owner', owner);
|
|
1190
1201
|
assert(`You attempted to mount the engine '${name}' in your router map, but the engine can not be found.`, owner.hasRegistration(`engine:${name}`));
|
|
1191
1202
|
engineInstance = owner.buildChildEngineInstance(name, {
|
|
1192
1203
|
routable: true,
|
|
@@ -1354,6 +1365,7 @@ function logError(_error, initialMessage) {
|
|
|
1354
1365
|
|
|
1355
1366
|
function findRouteSubstateName(route, state) {
|
|
1356
1367
|
let owner = getOwner(route);
|
|
1368
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1357
1369
|
let {
|
|
1358
1370
|
routeName,
|
|
1359
1371
|
fullRouteName,
|
|
@@ -1377,6 +1389,7 @@ function findRouteSubstateName(route, state) {
|
|
|
1377
1389
|
|
|
1378
1390
|
function findRouteStateName(route, state) {
|
|
1379
1391
|
let owner = getOwner(route);
|
|
1392
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1380
1393
|
let {
|
|
1381
1394
|
routeName,
|
|
1382
1395
|
fullRouteName,
|
|
@@ -1486,7 +1499,9 @@ function updatePaths(router) {
|
|
|
1486
1499
|
set(router, 'currentPath', path);
|
|
1487
1500
|
set(router, 'currentRouteName', currentRouteName);
|
|
1488
1501
|
set(router, 'currentURL', currentURL);
|
|
1489
|
-
let
|
|
1502
|
+
let owner = getOwner(router);
|
|
1503
|
+
assert('Router is unexpectedly missing an owner', owner);
|
|
1504
|
+
let appController = owner.lookup('controller:application');
|
|
1490
1505
|
|
|
1491
1506
|
if (!appController) {
|
|
1492
1507
|
// appController might not exist when top-level loading/error
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { get } from '@ember/-internals/metal';
|
|
2
2
|
import { getOwner } from '@ember/-internals/owner';
|
|
3
|
-
import { deprecate } from '@ember/debug';
|
|
3
|
+
import { assert, deprecate } from '@ember/debug';
|
|
4
4
|
import EmberError from '@ember/error';
|
|
5
5
|
import { STATE_SYMBOL } from 'router_js';
|
|
6
6
|
const ALL_PERIODS_REGEX = /\./g;
|
|
7
7
|
export function extractRouteArgs(args) {
|
|
8
8
|
args = args.slice();
|
|
9
|
-
let possibleQueryParams = args
|
|
9
|
+
let possibleQueryParams = args.pop();
|
|
10
10
|
let queryParams;
|
|
11
11
|
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
// `possibleQueryParams` -- defined as the last item in args -- both exists
|
|
15
|
-
// and has the property `queryParams`. If either of these invariants change,
|
|
16
|
-
// ***this is unsafe and should be changed***.
|
|
17
|
-
queryParams = args.pop().queryParams;
|
|
12
|
+
if (hasQueryParams(possibleQueryParams)) {
|
|
13
|
+
queryParams = possibleQueryParams.queryParams;
|
|
18
14
|
} else {
|
|
15
|
+
// Not query params so return to the array
|
|
16
|
+
args.push(possibleQueryParams);
|
|
19
17
|
queryParams = {};
|
|
20
18
|
} // UNSAFE: these are simply assumed as the existing behavior of the system.
|
|
21
19
|
// However, this could break if upstream refactors change it, and the types
|
|
@@ -185,12 +183,12 @@ function accumulateQueryParamDescriptors(_desc, accum) {
|
|
|
185
183
|
};
|
|
186
184
|
}
|
|
187
185
|
|
|
188
|
-
|
|
186
|
+
let val = accum[key] || {
|
|
189
187
|
as: null,
|
|
190
188
|
scope: 'model'
|
|
191
189
|
};
|
|
192
|
-
Object.assign(
|
|
193
|
-
accum[key] =
|
|
190
|
+
Object.assign(val, singleDesc);
|
|
191
|
+
accum[key] = val;
|
|
194
192
|
}
|
|
195
193
|
}
|
|
196
194
|
/*
|
|
@@ -212,6 +210,7 @@ export function resemblesURL(str) {
|
|
|
212
210
|
export function prefixRouteNameArg(route, args) {
|
|
213
211
|
let routeName = args[0];
|
|
214
212
|
let owner = getOwner(route);
|
|
213
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
215
214
|
let prefix = owner.mountPoint; // only alter the routeName if it's actually referencing a route.
|
|
216
215
|
|
|
217
216
|
if (owner.routable && typeof routeName === 'string') {
|
|
@@ -253,9 +252,22 @@ export function deprecateTransitionMethods(frameworkClass, methodName) {
|
|
|
253
252
|
id: 'routing.transition-methods',
|
|
254
253
|
for: 'ember-source',
|
|
255
254
|
since: {
|
|
255
|
+
available: '3.26.0',
|
|
256
256
|
enabled: '3.26.0'
|
|
257
257
|
},
|
|
258
258
|
until: '5.0.0',
|
|
259
259
|
url: 'https://deprecations.emberjs.com/v3.x/#toc_routing-transition-methods'
|
|
260
260
|
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function hasQueryParams(value) {
|
|
264
|
+
if (value && typeof value === 'object') {
|
|
265
|
+
let qps = value.queryParams;
|
|
266
|
+
|
|
267
|
+
if (qps && typeof qps === 'object') {
|
|
268
|
+
return Object.keys(qps).every(k => typeof k === 'string');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return false;
|
|
261
273
|
}
|
|
@@ -21,16 +21,16 @@ const ActionHandler = Mixin.create({
|
|
|
21
21
|
/**
|
|
22
22
|
The collection of functions, keyed by name, available on this
|
|
23
23
|
`ActionHandler` as action targets.
|
|
24
|
-
|
|
24
|
+
These functions will be invoked when a matching `{{action}}` is triggered
|
|
25
25
|
from within a template and the application's current route is this route.
|
|
26
|
-
|
|
26
|
+
Actions can also be invoked from other parts of your application
|
|
27
27
|
via `ActionHandler#send`.
|
|
28
|
-
|
|
28
|
+
The `actions` hash will inherit action handlers from
|
|
29
29
|
the `actions` hash defined on extended parent classes
|
|
30
30
|
or mixins rather than just replace the entire hash, e.g.:
|
|
31
|
-
|
|
31
|
+
```app/mixins/can-display-banner.js
|
|
32
32
|
import Mixin from '@ember/mixin';
|
|
33
|
-
|
|
33
|
+
export default Mixin.create({
|
|
34
34
|
actions: {
|
|
35
35
|
displayBanner(msg) {
|
|
36
36
|
// ...
|
|
@@ -38,28 +38,28 @@ const ActionHandler = Mixin.create({
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
```
|
|
41
|
-
|
|
41
|
+
```app/routes/welcome.js
|
|
42
42
|
import Route from '@ember/routing/route';
|
|
43
43
|
import CanDisplayBanner from '../mixins/can-display-banner';
|
|
44
|
-
|
|
44
|
+
export default Route.extend(CanDisplayBanner, {
|
|
45
45
|
actions: {
|
|
46
46
|
playMusic() {
|
|
47
47
|
// ...
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
// `WelcomeRoute`, when active, will be able to respond
|
|
52
52
|
// to both actions, since the actions hash is merged rather
|
|
53
53
|
// then replaced when extending mixins / parent classes.
|
|
54
54
|
this.send('displayBanner');
|
|
55
55
|
this.send('playMusic');
|
|
56
56
|
```
|
|
57
|
-
|
|
57
|
+
Within a Controller, Route or Component's action handler,
|
|
58
58
|
the value of the `this` context is the Controller, Route or
|
|
59
59
|
Component object:
|
|
60
|
-
|
|
60
|
+
```app/routes/song.js
|
|
61
61
|
import Route from '@ember/routing/route';
|
|
62
|
-
|
|
62
|
+
export default Route.extend({
|
|
63
63
|
actions: {
|
|
64
64
|
myAction() {
|
|
65
65
|
this.controllerFor("song");
|
|
@@ -69,13 +69,13 @@ const ActionHandler = Mixin.create({
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
|
-
|
|
72
|
+
It is also possible to call `this._super(...arguments)` from within an
|
|
73
73
|
action handler if it overrides a handler defined on a parent
|
|
74
74
|
class or mixin:
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
Take for example the following routes:
|
|
76
|
+
```app/mixins/debug-route.js
|
|
77
77
|
import Mixin from '@ember/mixin';
|
|
78
|
-
|
|
78
|
+
export default Mixin.create({
|
|
79
79
|
actions: {
|
|
80
80
|
debugRouteInformation() {
|
|
81
81
|
console.debug("It's a-me, console.debug!");
|
|
@@ -83,54 +83,54 @@ const ActionHandler = Mixin.create({
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
```
|
|
86
|
-
|
|
86
|
+
```app/routes/annoying-debug.js
|
|
87
87
|
import Route from '@ember/routing/route';
|
|
88
88
|
import DebugRoute from '../mixins/debug-route';
|
|
89
|
-
|
|
89
|
+
export default Route.extend(DebugRoute, {
|
|
90
90
|
actions: {
|
|
91
91
|
debugRouteInformation() {
|
|
92
92
|
// also call the debugRouteInformation of mixed in DebugRoute
|
|
93
93
|
this._super(...arguments);
|
|
94
|
-
|
|
94
|
+
// show additional annoyance
|
|
95
95
|
window.alert(...);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
```
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
## Bubbling
|
|
101
|
+
By default, an action will stop bubbling once a handler defined
|
|
102
102
|
on the `actions` hash handles it. To continue bubbling the action,
|
|
103
103
|
you must return `true` from the handler:
|
|
104
|
-
|
|
104
|
+
```app/router.js
|
|
105
105
|
Router.map(function() {
|
|
106
106
|
this.route("album", function() {
|
|
107
107
|
this.route("song");
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
```
|
|
111
|
-
|
|
111
|
+
```app/routes/album.js
|
|
112
112
|
import Route from '@ember/routing/route';
|
|
113
|
-
|
|
113
|
+
export default Route.extend({
|
|
114
114
|
actions: {
|
|
115
115
|
startPlaying: function() {
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
```
|
|
120
|
-
|
|
120
|
+
```app/routes/album-song.js
|
|
121
121
|
import Route from '@ember/routing/route';
|
|
122
|
-
|
|
122
|
+
export default Route.extend({
|
|
123
123
|
actions: {
|
|
124
124
|
startPlaying() {
|
|
125
125
|
// ...
|
|
126
|
-
|
|
126
|
+
if (actionShouldAlsoBeTriggeredOnParentRoute) {
|
|
127
127
|
return true;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
```
|
|
133
|
-
|
|
133
|
+
@property actions
|
|
134
134
|
@type Object
|
|
135
135
|
@default null
|
|
136
136
|
@public
|
|
@@ -140,14 +140,14 @@ const ActionHandler = Mixin.create({
|
|
|
140
140
|
Triggers a named action on the `ActionHandler`. Any parameters
|
|
141
141
|
supplied after the `actionName` string will be passed as arguments
|
|
142
142
|
to the action target function.
|
|
143
|
-
|
|
143
|
+
If the `ActionHandler` has its `target` property set, actions may
|
|
144
144
|
bubble to the `target`. Bubbling happens when an `actionName` can
|
|
145
145
|
not be found in the `ActionHandler`'s `actions` hash or if the
|
|
146
146
|
action target function returns `true`.
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
Example
|
|
148
|
+
```app/routes/welcome.js
|
|
149
149
|
import Route from '@ember/routing/route';
|
|
150
|
-
|
|
150
|
+
export default Route.extend({
|
|
151
151
|
actions: {
|
|
152
152
|
playTheme() {
|
|
153
153
|
this.send('playMusic', 'theme.mp3');
|
|
@@ -158,7 +158,7 @@ const ActionHandler = Mixin.create({
|
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
```
|
|
161
|
-
|
|
161
|
+
@method send
|
|
162
162
|
@param {String} actionName The action to trigger
|
|
163
163
|
@param {*} context a context to send with the action
|
|
164
164
|
@public
|
|
@@ -952,6 +952,7 @@ const ArrayMixin = Mixin.create(Enumerable, {
|
|
|
952
952
|
@return {Object} The reduced value.
|
|
953
953
|
@public
|
|
954
954
|
*/
|
|
955
|
+
// FIXME: When called without initialValue, behavior does not match native behavior
|
|
955
956
|
reduce(callback, initialValue) {
|
|
956
957
|
assert('`reduce` expects a function as first argument.', typeof callback === 'function');
|
|
957
958
|
let ret = initialValue;
|
|
@@ -18,13 +18,13 @@ import { Mixin } from '@ember/-internals/metal';
|
|
|
18
18
|
export default Mixin.create({
|
|
19
19
|
/**
|
|
20
20
|
__Required.__ You must implement this method to apply this mixin.
|
|
21
|
-
|
|
21
|
+
Override to return the result of the comparison of the two parameters. The
|
|
22
22
|
compare method should return:
|
|
23
|
-
|
|
23
|
+
- `-1` if `a < b`
|
|
24
24
|
- `0` if `a == b`
|
|
25
25
|
- `1` if `a > b`
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Default implementation raises an exception.
|
|
27
|
+
@method compare
|
|
28
28
|
@param a {Object} the first object to compare
|
|
29
29
|
@param b {Object} the second object to compare
|
|
30
30
|
@return {Number} the result of the comparison
|
|
@@ -15,7 +15,7 @@ import { Mixin } from '@ember/-internals/metal';
|
|
|
15
15
|
let containerProxyMixin = {
|
|
16
16
|
/**
|
|
17
17
|
The container stores state.
|
|
18
|
-
|
|
18
|
+
@private
|
|
19
19
|
@property {Ember.Container} __container__
|
|
20
20
|
*/
|
|
21
21
|
__container__: null,
|
|
@@ -23,16 +23,16 @@ let containerProxyMixin = {
|
|
|
23
23
|
/**
|
|
24
24
|
Returns an object that can be used to provide an owner to a
|
|
25
25
|
manually created instance.
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Example:
|
|
27
|
+
```
|
|
28
28
|
import { getOwner } from '@ember/application';
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
let owner = getOwner(this);
|
|
30
|
+
User.create(
|
|
31
31
|
owner.ownerInjection(),
|
|
32
32
|
{ username: 'rwjblue' }
|
|
33
33
|
)
|
|
34
34
|
```
|
|
35
|
-
|
|
35
|
+
@public
|
|
36
36
|
@method ownerInjection
|
|
37
37
|
@since 2.3.0
|
|
38
38
|
@return {Object}
|
|
@@ -43,30 +43,30 @@ let containerProxyMixin = {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
Given a fullName return a corresponding instance.
|
|
46
|
-
|
|
46
|
+
The default behavior is for lookup to return a singleton instance.
|
|
47
47
|
The singleton is scoped to the container, allowing multiple containers
|
|
48
48
|
to all have their own locally scoped singletons.
|
|
49
|
-
|
|
49
|
+
```javascript
|
|
50
50
|
let registry = new Registry();
|
|
51
51
|
let container = registry.container();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
registry.register('api:twitter', Twitter);
|
|
53
|
+
let twitter = container.lookup('api:twitter');
|
|
54
|
+
twitter instanceof Twitter; // => true
|
|
55
|
+
// by default the container will return singletons
|
|
56
56
|
let twitter2 = container.lookup('api:twitter');
|
|
57
57
|
twitter2 instanceof Twitter; // => true
|
|
58
|
-
|
|
58
|
+
twitter === twitter2; //=> true
|
|
59
59
|
```
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
If singletons are not wanted an optional flag can be provided at lookup.
|
|
61
|
+
```javascript
|
|
62
62
|
let registry = new Registry();
|
|
63
63
|
let container = registry.container();
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
registry.register('api:twitter', Twitter);
|
|
65
|
+
let twitter = container.lookup('api:twitter', { singleton: false });
|
|
66
66
|
let twitter2 = container.lookup('api:twitter', { singleton: false });
|
|
67
|
-
|
|
67
|
+
twitter === twitter2; //=> false
|
|
68
68
|
```
|
|
69
|
-
|
|
69
|
+
@public
|
|
70
70
|
@method lookup
|
|
71
71
|
@param {String} fullName
|
|
72
72
|
@param {Object} options
|
|
@@ -91,32 +91,32 @@ let containerProxyMixin = {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
Given a fullName return a factory manager.
|
|
94
|
-
|
|
94
|
+
This method returns a manager which can be used for introspection of the
|
|
95
95
|
factory's class or for the creation of factory instances with initial
|
|
96
96
|
properties. The manager is an object with the following properties:
|
|
97
|
-
|
|
97
|
+
* `class` - The registered or resolved class.
|
|
98
98
|
* `create` - A function that will create an instance of the class with
|
|
99
99
|
any dependencies injected.
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
For example:
|
|
101
|
+
```javascript
|
|
102
102
|
import { getOwner } from '@ember/application';
|
|
103
|
-
|
|
103
|
+
let owner = getOwner(otherInstance);
|
|
104
104
|
// the owner is commonly the `applicationInstance`, and can be accessed via
|
|
105
105
|
// an instance initializer.
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
let factory = owner.factoryFor('service:bespoke');
|
|
107
|
+
factory.class;
|
|
108
108
|
// The registered or resolved class. For example when used with an Ember-CLI
|
|
109
109
|
// app, this would be the default export from `app/services/bespoke.js`.
|
|
110
|
-
|
|
110
|
+
let instance = factory.create({
|
|
111
111
|
someProperty: 'an initial property value'
|
|
112
112
|
});
|
|
113
113
|
// Create an instance with any injections and the passed options as
|
|
114
114
|
// initial properties.
|
|
115
115
|
```
|
|
116
|
-
|
|
116
|
+
Any instances created via the factory's `.create()` method *must* be destroyed
|
|
117
117
|
manually by the caller of `.create()`. Typically, this is done during the creating
|
|
118
118
|
objects own `destroy` or `willDestroy` methods.
|
|
119
|
-
|
|
119
|
+
@public
|
|
120
120
|
@method factoryFor
|
|
121
121
|
@param {String} fullName
|
|
122
122
|
@param {Object} options
|
|
@@ -98,7 +98,7 @@ export default Mixin.create({
|
|
|
98
98
|
/**
|
|
99
99
|
If the proxied promise is rejected this will contain the reason
|
|
100
100
|
provided.
|
|
101
|
-
|
|
101
|
+
@property reason
|
|
102
102
|
@default null
|
|
103
103
|
@public
|
|
104
104
|
*/
|
|
@@ -106,7 +106,7 @@ export default Mixin.create({
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
Once the proxied promise has settled this will become `false`.
|
|
109
|
-
|
|
109
|
+
@property isPending
|
|
110
110
|
@default true
|
|
111
111
|
@public
|
|
112
112
|
*/
|
|
@@ -116,7 +116,7 @@ export default Mixin.create({
|
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
Once the proxied promise has settled this will become `true`.
|
|
119
|
-
|
|
119
|
+
@property isSettled
|
|
120
120
|
@default false
|
|
121
121
|
@public
|
|
122
122
|
*/
|
|
@@ -126,7 +126,7 @@ export default Mixin.create({
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
Will become `true` if the proxied promise is rejected.
|
|
129
|
-
|
|
129
|
+
@property isRejected
|
|
130
130
|
@default false
|
|
131
131
|
@public
|
|
132
132
|
*/
|
|
@@ -134,7 +134,7 @@ export default Mixin.create({
|
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
Will become `true` if the proxied promise is fulfilled.
|
|
137
|
-
|
|
137
|
+
@property isFulfilled
|
|
138
138
|
@default false
|
|
139
139
|
@public
|
|
140
140
|
*/
|
|
@@ -142,17 +142,17 @@ export default Mixin.create({
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
The promise whose fulfillment value is being proxied by this object.
|
|
145
|
-
|
|
145
|
+
This property must be specified upon creation, and should not be
|
|
146
146
|
changed once created.
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
Example:
|
|
148
|
+
```javascript
|
|
149
149
|
import ObjectProxy from '@ember/object/proxy';
|
|
150
150
|
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
151
|
-
|
|
151
|
+
ObjectProxy.extend(PromiseProxyMixin).create({
|
|
152
152
|
promise: <thenable>
|
|
153
153
|
});
|
|
154
154
|
```
|
|
155
|
-
|
|
155
|
+
@property promise
|
|
156
156
|
@public
|
|
157
157
|
*/
|
|
158
158
|
promise: computed({
|
|
@@ -168,8 +168,8 @@ export default Mixin.create({
|
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
An alias to the proxied promise's `then`.
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
See RSVP.Promise.then.
|
|
172
|
+
@method then
|
|
173
173
|
@param {Function} callback
|
|
174
174
|
@return {RSVP.Promise}
|
|
175
175
|
@public
|
|
@@ -178,8 +178,8 @@ export default Mixin.create({
|
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
An alias to the proxied promise's `catch`.
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
See RSVP.Promise.catch.
|
|
182
|
+
@method catch
|
|
183
183
|
@param {Function} callback
|
|
184
184
|
@return {RSVP.Promise}
|
|
185
185
|
@since 1.3.0
|
|
@@ -189,8 +189,8 @@ export default Mixin.create({
|
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
191
|
An alias to the proxied promise's `finally`.
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
See RSVP.Promise.finally.
|
|
193
|
+
@method finally
|
|
194
194
|
@param {Function} callback
|
|
195
195
|
@return {RSVP.Promise}
|
|
196
196
|
@since 1.3.0
|