ember-source 4.3.0-alpha.2 → 4.4.0-alpha.1
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/CHANGELOG.md +6 -2
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +66 -31
- package/dist/ember-template-compiler.js +1169 -779
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +74 -43
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3290 -2760
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +15 -11
- 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 +139 -103
- package/dist/packages/@ember/-internals/meta/lib/meta.js +8 -9
- package/dist/packages/@ember/-internals/metal/index.js +44 -45
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +10 -8
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +155 -190
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +110 -378
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +74 -36
- package/dist/packages/@ember/-internals/routing/lib/utils.js +33 -21
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- 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 +10 -8
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +2 -0
- package/dist/packages/@ember/array/index.js +1 -1
- package/dist/packages/@ember/controller/index.js +3 -54
- package/dist/packages/@ember/instrumentation/index.js +9 -13
- package/dist/packages/@ember/object/compat.js +16 -7
- package/dist/packages/@ember/routing/router-service.js +1 -0
- package/dist/packages/@ember/service/index.js +6 -73
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +571 -521
- package/package.json +13 -13
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length,
|
|
3
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
4
|
+
d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
import { getOwner } from '@ember/-internals/owner';
|
|
2
10
|
import { Evented } from '@ember/-internals/runtime';
|
|
3
11
|
import { symbol } from '@ember/-internals/utils';
|
|
@@ -15,40 +23,106 @@ function cleanURL(url, rootURL) {
|
|
|
15
23
|
|
|
16
24
|
return url.substr(rootURL.length, url.length);
|
|
17
25
|
}
|
|
18
|
-
/**
|
|
19
|
-
The Router service is the public API that provides access to the router.
|
|
20
|
-
|
|
21
|
-
The immediate benefit of the Router service is that you can inject it into components,
|
|
22
|
-
giving them a friendly way to initiate transitions and ask questions about the current
|
|
23
|
-
global router state.
|
|
24
|
-
|
|
25
|
-
In this example, the Router service is injected into a component to initiate a transition
|
|
26
|
-
to a dedicated route:
|
|
27
|
-
|
|
28
|
-
```app/components/example.js
|
|
29
|
-
import Component from '@glimmer/component';
|
|
30
|
-
import { action } from '@ember/object';
|
|
31
|
-
import { service } from '@ember/service';
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
class RouterService extends Service.extend(Evented) {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
/**
|
|
31
|
+
The `routeWillChange` event is fired at the beginning of any
|
|
32
|
+
attempted transition with a `Transition` object as the sole
|
|
33
|
+
argument. This action can be used for aborting, redirecting,
|
|
34
|
+
or decorating the transition from the currently active routes.
|
|
35
|
+
A good example is preventing navigation when a form is
|
|
36
|
+
half-filled out:
|
|
37
|
+
```app/routes/contact-form.js
|
|
38
|
+
import Route from '@ember/routing';
|
|
39
|
+
import { service } from '@ember/service';
|
|
40
|
+
export default class extends Route {
|
|
41
|
+
@service router;
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.router.on('routeWillChange', (transition) => {
|
|
45
|
+
if (!transition.to.find(route => route.name === this.routeName)) {
|
|
46
|
+
alert("Please save or cancel your changes.");
|
|
47
|
+
transition.abort();
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
The `routeWillChange` event fires whenever a new route is chosen as the desired target of a transition. This includes `transitionTo`, `replaceWith`, all redirection for any reason including error handling, and abort. Aborting implies changing the desired target back to where you already were. Once a transition has completed, `routeDidChange` fires.
|
|
54
|
+
@event routeWillChange
|
|
55
|
+
@param {Transition} transition
|
|
56
|
+
@public
|
|
57
|
+
*/
|
|
35
58
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
59
|
+
/**
|
|
60
|
+
The `routeDidChange` event only fires once a transition has settled.
|
|
61
|
+
This includes aborts and error substates. Like the `routeWillChange` event
|
|
62
|
+
it receives a Transition as the sole argument.
|
|
63
|
+
A good example is sending some analytics when the route has transitioned:
|
|
64
|
+
```app/routes/contact-form.js
|
|
65
|
+
import Route from '@ember/routing';
|
|
66
|
+
import { service } from '@ember/service';
|
|
67
|
+
export default class extends Route {
|
|
68
|
+
@service router;
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
this.router.on('routeDidChange', (transition) => {
|
|
72
|
+
ga.send('pageView', {
|
|
73
|
+
current: transition.to.name,
|
|
74
|
+
from: transition.from.name
|
|
75
|
+
});
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
`routeDidChange` will be called after any `Route`'s
|
|
81
|
+
[didTransition](/ember/release/classes/Route/events/didTransition?anchor=didTransition)
|
|
82
|
+
action has been fired.
|
|
83
|
+
The updates of properties
|
|
84
|
+
[currentURL](/ember/release/classes/RouterService/properties/currentURL?anchor=currentURL),
|
|
85
|
+
[currentRouteName](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRouteName)
|
|
86
|
+
and
|
|
87
|
+
[currentRoute](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRoute)
|
|
88
|
+
are completed at the time `routeDidChange` is called.
|
|
89
|
+
@event routeDidChange
|
|
90
|
+
@param {Transition} transition
|
|
91
|
+
@public
|
|
92
|
+
*/
|
|
93
|
+
// Canary features
|
|
42
94
|
|
|
43
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Refreshes all currently active routes, doing a full transition.
|
|
97
|
+
* If a route name is provided and refers to a currently active route,
|
|
98
|
+
* it will refresh only that route and its descendents.
|
|
99
|
+
* Returns a promise that will be resolved once the refresh is complete.
|
|
100
|
+
* All resetController, beforeModel, model, afterModel, redirect, and setupController
|
|
101
|
+
* hooks will be called again. You will get new data from the model hook.
|
|
102
|
+
*
|
|
103
|
+
* @method refresh
|
|
104
|
+
* @param {String} [routeName] the route to refresh (along with all child routes)
|
|
105
|
+
* @return Transition
|
|
106
|
+
* @category EMBER_ROUTING_ROUTER_SERVICE_REFRESH
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
44
109
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
110
|
+
this.refresh = true
|
|
111
|
+
/* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
|
|
112
|
+
? function (pivotRouteName) {
|
|
113
|
+
if (!pivotRouteName) {
|
|
114
|
+
return this._router._routerMicrolib.refresh();
|
|
115
|
+
}
|
|
49
116
|
|
|
117
|
+
assert(`The route "${pivotRouteName}" was not found`, this._router.hasRoute(pivotRouteName));
|
|
118
|
+
assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
|
|
119
|
+
let owner = getOwner(this);
|
|
120
|
+
assert('RouterService is unexpectedly missing an owner', owner);
|
|
121
|
+
let pivotRoute = owner.lookup(`route:${pivotRouteName}`);
|
|
122
|
+
return this._router._routerMicrolib.refresh(pivotRoute);
|
|
123
|
+
} : undefined;
|
|
124
|
+
}
|
|
50
125
|
|
|
51
|
-
export default class RouterService extends Service {
|
|
52
126
|
get _router() {
|
|
53
127
|
let router = this[ROUTER];
|
|
54
128
|
|
|
@@ -56,15 +130,55 @@ export default class RouterService extends Service {
|
|
|
56
130
|
return router;
|
|
57
131
|
}
|
|
58
132
|
|
|
59
|
-
|
|
133
|
+
let owner = getOwner(this);
|
|
134
|
+
assert('RouterService is unexpectedly missing an owner', owner);
|
|
60
135
|
router = owner.lookup('router:main');
|
|
61
136
|
return this[ROUTER] = router;
|
|
62
137
|
}
|
|
63
138
|
|
|
64
139
|
willDestroy() {
|
|
65
|
-
super.willDestroy(
|
|
140
|
+
super.willDestroy();
|
|
66
141
|
this[ROUTER] = null;
|
|
67
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
Transition the application into another route. The route may
|
|
145
|
+
be either a single route or route path:
|
|
146
|
+
Calling `transitionTo` from the Router service will cause default query parameter values to be included in the URL.
|
|
147
|
+
This behavior is different from calling `transitionTo` on a route or `transitionToRoute` on a controller.
|
|
148
|
+
See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info.
|
|
149
|
+
In the following example we use the Router service to navigate to a route with a
|
|
150
|
+
specific model from a Component in the first action, and in the second we trigger
|
|
151
|
+
a query-params only transition.
|
|
152
|
+
```app/components/example.js
|
|
153
|
+
import Component from '@glimmer/component';
|
|
154
|
+
import { action } from '@ember/object';
|
|
155
|
+
import { service } from '@ember/service';
|
|
156
|
+
export default class extends Component {
|
|
157
|
+
@service router;
|
|
158
|
+
@action
|
|
159
|
+
goToComments(post) {
|
|
160
|
+
this.router.transitionTo('comments', post);
|
|
161
|
+
}
|
|
162
|
+
@action
|
|
163
|
+
fetchMoreComments(latestComment) {
|
|
164
|
+
this.router.transitionTo({
|
|
165
|
+
queryParams: { commentsAfter: latestComment }
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
@method transitionTo
|
|
171
|
+
@param {String} [routeNameOrUrl] the name of the route or a URL
|
|
172
|
+
@param {...Object} [models] the model(s) or identifier(s) to be used while
|
|
173
|
+
transitioning to the route.
|
|
174
|
+
@param {Object} [options] optional hash with a queryParams property
|
|
175
|
+
containing a mapping of query parameters. May be supplied as the only
|
|
176
|
+
parameter to trigger a query-parameter-only transition.
|
|
177
|
+
@return {Transition} the transition object associated with this
|
|
178
|
+
attempted transition
|
|
179
|
+
@public
|
|
180
|
+
*/
|
|
181
|
+
|
|
68
182
|
|
|
69
183
|
transitionTo(...args) {
|
|
70
184
|
if (resemblesURL(args[0])) {
|
|
@@ -90,7 +204,6 @@ export default class RouterService extends Service {
|
|
|
90
204
|
When the user clicks the "back" button in the browser, there will be fewer steps.
|
|
91
205
|
This is most commonly used to manage redirects in a way that does not cause confusing additions
|
|
92
206
|
to the user's browsing history.
|
|
93
|
-
See [replaceWith](/ember/release/classes/Route/methods/replaceWith?anchor=replaceWith) for more info.
|
|
94
207
|
Calling `replaceWith` from the Router service will cause default query parameter values to be included in the URL.
|
|
95
208
|
This behavior is different from calling `replaceWith` on a route.
|
|
96
209
|
See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info.
|
|
@@ -117,8 +230,8 @@ export default class RouterService extends Service {
|
|
|
117
230
|
*/
|
|
118
231
|
|
|
119
232
|
|
|
120
|
-
replaceWith() {
|
|
121
|
-
return this.transitionTo(...
|
|
233
|
+
replaceWith(...args) {
|
|
234
|
+
return this.transitionTo(...args).method('replace');
|
|
122
235
|
}
|
|
123
236
|
/**
|
|
124
237
|
Generate a URL based on the supplied route name and optionally a model. The
|
|
@@ -171,8 +284,7 @@ export default class RouterService extends Service {
|
|
|
171
284
|
```
|
|
172
285
|
@method urlFor
|
|
173
286
|
@param {String} routeName the name of the route
|
|
174
|
-
@param {...Object} models the model(s)
|
|
175
|
-
transitioning to the route.
|
|
287
|
+
@param {...Object} models the model(s) for the route.
|
|
176
288
|
@param {Object} [options] optional hash with a queryParams property
|
|
177
289
|
containing a mapping of query parameters
|
|
178
290
|
@return {String} the string representing the generated URL
|
|
@@ -293,6 +405,7 @@ export default class RouterService extends Service {
|
|
|
293
405
|
```
|
|
294
406
|
@method recognize
|
|
295
407
|
@param {String} url
|
|
408
|
+
@return {RouteInfo | null}
|
|
296
409
|
@public
|
|
297
410
|
*/
|
|
298
411
|
|
|
@@ -313,6 +426,7 @@ export default class RouterService extends Service {
|
|
|
313
426
|
the browser including the app's `rootURL`.
|
|
314
427
|
@method recognizeAndLoad
|
|
315
428
|
@param {String} url
|
|
429
|
+
@return {RouteInfo}
|
|
316
430
|
@public
|
|
317
431
|
*/
|
|
318
432
|
|
|
@@ -328,163 +442,14 @@ export default class RouterService extends Service {
|
|
|
328
442
|
|
|
329
443
|
}
|
|
330
444
|
|
|
331
|
-
|
|
332
|
-
/* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
|
|
333
|
-
) {
|
|
334
|
-
RouterService.reopen({
|
|
335
|
-
/**
|
|
336
|
-
* Refreshes all currently active routes, doing a full transition.
|
|
337
|
-
* If a route name is provided and refers to a currently active route,
|
|
338
|
-
* it will refresh only that route and its descendents.
|
|
339
|
-
* Returns a promise that will be resolved once the refresh is complete.
|
|
340
|
-
* All resetController, beforeModel, model, afterModel, redirect, and setupController
|
|
341
|
-
* hooks will be called again. You will get new data from the model hook.
|
|
342
|
-
*
|
|
343
|
-
* @method refresh
|
|
344
|
-
* @param {String} [routeName] the route to refresh (along with all child routes)
|
|
345
|
-
* @return Transition
|
|
346
|
-
* @category EMBER_ROUTING_ROUTER_SERVICE_REFRESH
|
|
347
|
-
* @public
|
|
348
|
-
*/
|
|
349
|
-
refresh(pivotRouteName) {
|
|
350
|
-
if (!pivotRouteName) {
|
|
351
|
-
return this._router._routerMicrolib.refresh();
|
|
352
|
-
}
|
|
445
|
+
__decorate([readOnly('_router.currentRouteName')], RouterService.prototype, "currentRouteName", void 0);
|
|
353
446
|
|
|
354
|
-
|
|
355
|
-
assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
|
|
356
|
-
let pivotRoute = getOwner(this).lookup(`route:${pivotRouteName}`);
|
|
357
|
-
return this._router._routerMicrolib.refresh(pivotRoute);
|
|
358
|
-
}
|
|
447
|
+
__decorate([readOnly('_router.currentURL')], RouterService.prototype, "currentURL", void 0);
|
|
359
448
|
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
RouterService.reopen(Evented, {
|
|
364
|
-
/**
|
|
365
|
-
Name of the current route.
|
|
366
|
-
This property represents the logical name of the route,
|
|
367
|
-
which is comma separated.
|
|
368
|
-
For the following router:
|
|
369
|
-
```app/router.js
|
|
370
|
-
Router.map(function() {
|
|
371
|
-
this.route('about');
|
|
372
|
-
this.route('blog', function () {
|
|
373
|
-
this.route('post', { path: ':post_id' });
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
```
|
|
377
|
-
It will return:
|
|
378
|
-
* `index` when you visit `/`
|
|
379
|
-
* `about` when you visit `/about`
|
|
380
|
-
* `blog.index` when you visit `/blog`
|
|
381
|
-
* `blog.post` when you visit `/blog/some-post-id`
|
|
382
|
-
@property currentRouteName
|
|
383
|
-
@type String
|
|
384
|
-
@public
|
|
385
|
-
*/
|
|
386
|
-
currentRouteName: readOnly('_router.currentRouteName'),
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
Current URL for the application.
|
|
390
|
-
This property represents the URL path for this route.
|
|
391
|
-
For the following router:
|
|
392
|
-
```app/router.js
|
|
393
|
-
Router.map(function() {
|
|
394
|
-
this.route('about');
|
|
395
|
-
this.route('blog', function () {
|
|
396
|
-
this.route('post', { path: ':post_id' });
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
```
|
|
400
|
-
It will return:
|
|
401
|
-
* `/` when you visit `/`
|
|
402
|
-
* `/about` when you visit `/about`
|
|
403
|
-
* `/blog` when you visit `/blog`
|
|
404
|
-
* `/blog/some-post-id` when you visit `/blog/some-post-id`
|
|
405
|
-
@property currentURL
|
|
406
|
-
@type String
|
|
407
|
-
@public
|
|
408
|
-
*/
|
|
409
|
-
currentURL: readOnly('_router.currentURL'),
|
|
449
|
+
__decorate([readOnly('_router.location')], RouterService.prototype, "location", void 0);
|
|
410
450
|
|
|
411
|
-
|
|
412
|
-
The `location` property returns what implementation of the `location` API
|
|
413
|
-
your application is using, which determines what type of URL is being used.
|
|
414
|
-
See [Location](/ember/release/classes/Location) for more information.
|
|
415
|
-
To force a particular `location` API implementation to be used in your
|
|
416
|
-
application you can set a location type on your `config/environment`.
|
|
417
|
-
For example, to set the `history` type:
|
|
418
|
-
```config/environment.js
|
|
419
|
-
'use strict';
|
|
420
|
-
module.exports = function(environment) {
|
|
421
|
-
let ENV = {
|
|
422
|
-
modulePrefix: 'router-service',
|
|
423
|
-
environment,
|
|
424
|
-
rootURL: '/',
|
|
425
|
-
locationType: 'history',
|
|
426
|
-
...
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
```
|
|
430
|
-
The following location types are available by default:
|
|
431
|
-
`auto`, `hash`, `history`, `none`.
|
|
432
|
-
See [HashLocation](/ember/release/classes/HashLocation).
|
|
433
|
-
See [HistoryLocation](/ember/release/classes/HistoryLocation).
|
|
434
|
-
See [NoneLocation](/ember/release/classes/NoneLocation).
|
|
435
|
-
See [AutoLocation](/ember/release/classes/AutoLocation).
|
|
436
|
-
@property location
|
|
437
|
-
@default 'hash'
|
|
438
|
-
@see {Location}
|
|
439
|
-
@public
|
|
440
|
-
*/
|
|
441
|
-
location: readOnly('_router.location'),
|
|
451
|
+
__decorate([readOnly('_router.rootURL')], RouterService.prototype, "rootURL", void 0);
|
|
442
452
|
|
|
443
|
-
|
|
444
|
-
The `rootURL` property represents the URL of the root of
|
|
445
|
-
the application, '/' by default.
|
|
446
|
-
This prefix is assumed on all routes defined on this app.
|
|
447
|
-
If you change the `rootURL` in your environment configuration
|
|
448
|
-
like so:
|
|
449
|
-
```config/environment.js
|
|
450
|
-
'use strict';
|
|
451
|
-
module.exports = function(environment) {
|
|
452
|
-
let ENV = {
|
|
453
|
-
modulePrefix: 'router-service',
|
|
454
|
-
environment,
|
|
455
|
-
rootURL: '/my-root',
|
|
456
|
-
…
|
|
457
|
-
}
|
|
458
|
-
]
|
|
459
|
-
```
|
|
460
|
-
This property will return `/my-root`.
|
|
461
|
-
@property rootURL
|
|
462
|
-
@default '/'
|
|
463
|
-
@public
|
|
464
|
-
*/
|
|
465
|
-
rootURL: readOnly('_router.rootURL'),
|
|
453
|
+
__decorate([readOnly('_router.currentRoute')], RouterService.prototype, "currentRoute", void 0);
|
|
466
454
|
|
|
467
|
-
|
|
468
|
-
The `currentRoute` property contains metadata about the current leaf route.
|
|
469
|
-
It returns a `RouteInfo` object that has information like the route name,
|
|
470
|
-
params, query params and more.
|
|
471
|
-
See [RouteInfo](/ember/release/classes/RouteInfo) for more info.
|
|
472
|
-
This property is guaranteed to change whenever a route transition
|
|
473
|
-
happens (even when that transition only changes parameters
|
|
474
|
-
and doesn't change the active route).
|
|
475
|
-
Usage example:
|
|
476
|
-
```app/components/header.js
|
|
477
|
-
import Component from '@glimmer/component';
|
|
478
|
-
import { service } from '@ember/service';
|
|
479
|
-
import { notEmpty } from '@ember/object/computed';
|
|
480
|
-
export default class extends Component {
|
|
481
|
-
@service router;
|
|
482
|
-
@notEmpty('router.currentRoute.child') isChildRoute;
|
|
483
|
-
});
|
|
484
|
-
```
|
|
485
|
-
@property currentRoute
|
|
486
|
-
@type RouteInfo
|
|
487
|
-
@public
|
|
488
|
-
*/
|
|
489
|
-
currentRoute: readOnly('_router.currentRoute')
|
|
490
|
-
});
|
|
455
|
+
export { RouterService as default };
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { getOwner } from '@ember/-internals/owner';
|
|
5
5
|
import { symbol } from '@ember/-internals/utils';
|
|
6
|
+
import { assert } from '@ember/debug';
|
|
6
7
|
import { readOnly } from '@ember/object/computed';
|
|
7
8
|
import Service from '@ember/service';
|
|
8
9
|
const ROUTER = symbol('ROUTER');
|
|
@@ -25,7 +26,8 @@ export default class RoutingService extends Service {
|
|
|
25
26
|
return router;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
let owner = getOwner(this);
|
|
30
|
+
assert('RoutingService is unexpectedly missing an owner', owner);
|
|
29
31
|
router = owner.lookup('router:main');
|
|
30
32
|
router.setupRouter();
|
|
31
33
|
return this[ROUTER] = router;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
/**
|
|
3
3
|
A `RouteInfoWithAttributes` is an object that contains
|
|
4
4
|
metadata, including the resolved value from the routes
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
/**
|
|
56
56
|
This is the resolved return value from the
|
|
57
57
|
route's model hook.
|
|
58
|
-
@property {Object|Array|String} attributes
|
|
58
|
+
@property {Object|Array|String|undefined} attributes
|
|
59
59
|
@public
|
|
60
60
|
*/
|
|
61
61
|
|