ember-source 4.8.0-alpha.5 → 4.8.0-beta.2
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 +11 -2
- package/blueprints/helper/files/__root__/{__collection__ → helpers}/__name__.ts +0 -0
- package/blueprints/helper/index.js +0 -15
- package/blueprints/helper-test/index.js +0 -3
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints/helper-test/mocha-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.ts +0 -0
- package/blueprints/helper-test/qunit-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.ts +0 -0
- package/blueprints-js/helper/files/__root__/{__collection__ → helpers}/__name__.js +0 -0
- package/blueprints-js/helper-test/mocha-0.12-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/mocha-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/qunit-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +1 -1
- package/dist/ember-template-compiler.js +675 -18
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +11 -11
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +19576 -20510
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/glimmer/index.js +4 -2
- package/dist/packages/@ember/-internals/metal/index.js +214 -1094
- package/dist/packages/@ember/-internals/routing/index.js +1 -17
- package/dist/packages/@ember/-internals/runtime/index.js +3 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +2 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +4 -3
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +1 -8
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +2 -1
- package/dist/packages/@ember/-internals/utils/index.js +3 -3
- package/dist/packages/@ember/-internals/views/lib/component_lookup.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/view_state_support.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/views/core_view.js +3 -1
- package/dist/packages/@ember/application/index.js +876 -2
- package/dist/packages/@ember/application/instance.js +2 -2
- package/dist/packages/@ember/application/namespace.js +70 -1
- package/dist/packages/@ember/array/index.js +1503 -2
- package/dist/packages/@ember/array/mutable.js +1 -1
- package/dist/packages/@ember/array/proxy.js +307 -1
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/controller/index.js +260 -3
- package/dist/packages/@ember/debug/container-debug-adapter.js +99 -1
- package/dist/packages/@ember/debug/data-adapter.js +574 -1
- package/dist/packages/@ember/engine/index.js +5 -5
- package/dist/packages/@ember/engine/instance.js +4 -4
- package/dist/packages/@ember/enumerable/index.js +3 -1
- package/dist/packages/@ember/enumerable/mutable.js +4 -0
- package/dist/packages/@ember/{-internals/runtime/lib/system/object.js → object/-internals.js} +4 -17
- package/dist/packages/@ember/object/core.js +731 -1
- package/dist/packages/@ember/object/evented.js +93 -2
- package/dist/packages/@ember/object/index.js +76 -4
- package/dist/packages/@ember/object/internals.js +3 -2
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +3 -1
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +4 -3
- package/dist/packages/@ember/object/mixin.js +659 -1
- package/dist/packages/@ember/object/observable.js +341 -1
- package/dist/packages/@ember/object/promise-proxy-mixin.js +150 -1
- package/dist/packages/@ember/object/proxy.js +10 -1
- package/dist/packages/@ember/routing/-internals.js +7 -0
- package/dist/packages/@ember/routing/auto-location.js +249 -1
- package/dist/packages/@ember/routing/hash-location.js +169 -1
- package/dist/packages/@ember/routing/history-location.js +289 -1
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/cache.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/controller_for.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/dsl.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/engines.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/generate_controller.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/location/util.js → routing/lib/location-utils.js} +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/query_params.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/route-info.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/router_state.js +1 -1
- package/dist/packages/@ember/{-internals/routing/lib/services/routing.js → routing/lib/routing-service.js} +2 -2
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/transition.js +0 -0
- package/dist/packages/@ember/{-internals/routing → routing}/lib/utils.js +0 -0
- package/dist/packages/@ember/routing/location.js +104 -1
- package/dist/packages/@ember/routing/none-location.js +123 -1
- package/dist/packages/@ember/routing/route.js +1700 -1
- package/dist/packages/@ember/routing/router-service.js +510 -1
- package/dist/packages/@ember/routing/router.js +1666 -1
- package/dist/packages/@ember/service/index.js +1 -1
- package/dist/packages/@ember/utils/index.js +7 -2
- package/dist/packages/@ember/{-internals/runtime → utils}/lib/compare.js +2 -2
- package/dist/packages/@ember/{-internals/runtime → utils}/lib/is-equal.js +0 -0
- package/dist/packages/@ember/utils/lib/is_blank.js +35 -0
- package/dist/packages/@ember/utils/lib/is_empty.js +68 -0
- package/dist/packages/@ember/utils/lib/is_none.js +27 -0
- package/dist/packages/@ember/utils/lib/is_present.js +38 -0
- package/dist/packages/@ember/{-internals/runtime → utils}/lib/type-of.js +2 -2
- package/dist/packages/ember/index.js +47 -28
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/lib/adapters/adapter.js +1 -1
- package/dist/packages/ember-testing/lib/helpers/current_path.js +2 -2
- package/dist/packages/ember-testing/lib/helpers/current_route_name.js +2 -2
- package/dist/packages/ember-testing/lib/helpers/current_url.js +1 -1
- package/docs/data.json +9428 -9189
- package/package.json +23 -8
- package/types/preview/@ember/-internals/resolver.d.ts +35 -0
- package/types/preview/@ember/application/-private/event-dispatcher.d.ts +18 -0
- package/types/preview/@ember/application/-private/registry.d.ts +15 -0
- package/types/preview/@ember/application/deprecations.d.ts +24 -0
- package/types/preview/@ember/application/index.d.ts +153 -0
- package/types/preview/@ember/application/instance.d.ts +9 -0
- package/types/preview/@ember/application/tsconfig.json +3 -0
- package/types/preview/@ember/application/types.d.ts +29 -0
- package/types/preview/@ember/array/-private/enumerable.d.ts +13 -0
- package/types/preview/@ember/array/-private/mutable-enumerable.d.ts +13 -0
- package/types/preview/@ember/array/-private/native-array.d.ts +23 -0
- package/types/preview/@ember/array/index.d.ts +243 -0
- package/types/preview/@ember/array/mutable.d.ts +94 -0
- package/types/preview/@ember/array/proxy.d.ts +29 -0
- package/types/preview/@ember/array/tsconfig.json +3 -0
- package/types/preview/@ember/component/-private/class-names-support.d.ts +27 -0
- package/types/preview/@ember/component/-private/core-view.d.ts +14 -0
- package/types/preview/@ember/component/-private/glimmer-interfaces.d.ts +45 -0
- package/types/preview/@ember/component/-private/signature-utils.d.ts +107 -0
- package/types/preview/@ember/component/-private/view-mixin.d.ts +59 -0
- package/types/preview/@ember/component/helper.d.ts +122 -0
- package/types/preview/@ember/component/index.d.ts +132 -0
- package/types/preview/@ember/component/template-only.d.ts +47 -0
- package/types/preview/@ember/component/tsconfig.json +3 -0
- package/types/preview/@ember/controller/index.d.ts +48 -0
- package/types/preview/@ember/controller/tsconfig.json +3 -0
- package/types/preview/@ember/debug/container-debug-adapter.d.ts +13 -0
- package/types/preview/@ember/debug/data-adapter.d.ts +64 -0
- package/types/preview/@ember/debug/index.d.ts +98 -0
- package/types/preview/@ember/debug/tsconfig.json +3 -0
- package/types/preview/@ember/destroyable/index.d.ts +23 -0
- package/types/preview/@ember/destroyable/tsconfig.json +3 -0
- package/types/preview/@ember/engine/-private/container-proxy-mixin.d.ts +17 -0
- package/types/preview/@ember/engine/-private/registry-proxy-mixin.d.ts +54 -0
- package/types/preview/@ember/engine/-private/types/initializer.d.ts +8 -0
- package/types/preview/@ember/engine/index.d.ts +45 -0
- package/types/preview/@ember/engine/instance.d.ts +24 -0
- package/types/preview/@ember/engine/tsconfig.json +3 -0
- package/types/preview/@ember/error/index.d.ts +6 -0
- package/types/preview/@ember/error/tsconfig.json +3 -0
- package/types/preview/@ember/helper/index.d.ts +49 -0
- package/types/preview/@ember/helper/tsconfig.json +3 -0
- package/types/preview/@ember/modifier/index.d.ts +33 -0
- package/types/preview/@ember/modifier/tsconfig.json +3 -0
- package/types/preview/@ember/object/-private/action-handler.d.ts +31 -0
- package/types/preview/@ember/object/-private/types.d.ts +63 -0
- package/types/preview/@ember/object/compat.d.ts +9 -0
- package/types/preview/@ember/object/computed.d.ts +263 -0
- package/types/preview/@ember/object/core.d.ts +89 -0
- package/types/preview/@ember/object/evented.d.ts +45 -0
- package/types/preview/@ember/object/events.d.ts +47 -0
- package/types/preview/@ember/object/index.d.ts +126 -0
- package/types/preview/@ember/object/internals.d.ts +17 -0
- package/types/preview/@ember/object/mixin.d.ts +19 -0
- package/types/preview/@ember/object/observable.d.ts +89 -0
- package/types/preview/@ember/object/observers.d.ts +34 -0
- package/types/preview/@ember/object/promise-proxy-mixin.d.ts +37 -0
- package/types/preview/@ember/object/proxy.d.ts +27 -0
- package/types/preview/@ember/object/tsconfig.json +3 -0
- package/types/preview/@ember/owner/index.d.ts +102 -0
- package/types/preview/@ember/owner/tsconfig.json +3 -0
- package/types/preview/@ember/polyfills/index.d.ts +23 -0
- package/types/preview/@ember/polyfills/tsconfig.json +3 -0
- package/types/preview/@ember/polyfills/types.d.ts +6 -0
- package/types/preview/@ember/routing/-private/router-dsl.d.ts +20 -0
- package/types/preview/@ember/routing/auto-location.d.ts +8 -0
- package/types/preview/@ember/routing/hash-location.d.ts +10 -0
- package/types/preview/@ember/routing/history-location.d.ts +9 -0
- package/types/preview/@ember/routing/index.d.ts +20 -0
- package/types/preview/@ember/routing/none-location.d.ts +11 -0
- package/types/preview/@ember/routing/route-info.d.ts +74 -0
- package/types/preview/@ember/routing/route.d.ts +533 -0
- package/types/preview/@ember/routing/router-service.d.ts +351 -0
- package/types/preview/@ember/routing/router.d.ts +49 -0
- package/types/preview/@ember/routing/transition.d.ts +126 -0
- package/types/preview/@ember/routing/tsconfig.json +3 -0
- package/types/preview/@ember/routing/types.d.ts +15 -0
- package/types/preview/@ember/runloop/-private/backburner.d.ts +43 -0
- package/types/preview/@ember/runloop/-private/types.d.ts +9 -0
- package/types/preview/@ember/runloop/index.d.ts +175 -0
- package/types/preview/@ember/runloop/tsconfig.json +3 -0
- package/types/preview/@ember/runloop/types.d.ts +5 -0
- package/types/preview/@ember/service/index.d.ts +25 -0
- package/types/preview/@ember/service/tsconfig.json +3 -0
- package/types/preview/@ember/string/index.d.ts +9 -0
- package/types/preview/@ember/string/tsconfig.json +3 -0
- package/types/preview/@ember/template/-private/handlebars.d.ts +7 -0
- package/types/preview/@ember/template/index.d.ts +5 -0
- package/types/preview/@ember/template/tsconfig.json +3 -0
- package/types/preview/@ember/test/adapter.d.ts +22 -0
- package/types/preview/@ember/test/index.d.ts +49 -0
- package/types/preview/@ember/test/tsconfig.json +3 -0
- package/types/preview/@ember/utils/-private/types.d.ts +39 -0
- package/types/preview/@ember/utils/index.d.ts +42 -0
- package/types/preview/@ember/utils/tsconfig.json +3 -0
- package/types/preview/ember/-private/type-utils.d.ts +54 -0
- package/types/preview/ember/index.d.ts +381 -0
- package/types/preview/ember/tsconfig.json +3 -0
- package/types/preview/index.d.ts +120 -0
- package/types/preview/tsconfig.json +6 -0
- package/blueprints/helper/mu-files/__root__/__collection__/__name__.js +0 -7
- package/blueprints-js/helper/mu-files/__root__/__collection__/__name__.js +0 -7
- package/dist/packages/@ember/-internals/extension-support/index.js +0 -2
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +0 -96
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +0 -576
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +0 -224
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +0 -104
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +0 -250
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +0 -170
- package/dist/packages/@ember/-internals/routing/lib/location/history_location.js +0 -290
- package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +0 -124
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +0 -506
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +0 -1696
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +0 -1662
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +0 -1501
- package/dist/packages/@ember/-internals/runtime/lib/mixins/enumerable.js +0 -3
- package/dist/packages/@ember/-internals/runtime/lib/mixins/evented.js +0 -91
- package/dist/packages/@ember/-internals/runtime/lib/mixins/mutable_enumerable.js +0 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +0 -339
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +0 -149
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +0 -305
- package/dist/packages/@ember/-internals/runtime/lib/system/core_object.js +0 -730
- package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +0 -69
- package/dist/packages/@ember/-internals/runtime/lib/system/object_proxy.js +0 -7
- package/dist/packages/@ember/application/lib/application.js +0 -870
- package/dist/packages/@ember/controller/lib/controller_mixin.js +0 -42
- package/dist/packages/@ember/runloop/type-tests.ts/begin-end.test.js +0 -5
- package/dist/packages/@ember/runloop/type-tests.ts/bind.test.js +0 -59
- package/dist/packages/@ember/runloop/type-tests.ts/cancel.test.js +0 -5
- package/dist/packages/@ember/runloop/type-tests.ts/debounce.test.js +0 -77
- package/dist/packages/@ember/runloop/type-tests.ts/join.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/later.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/next.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/once.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/run.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/schedule-once.test.js +0 -39
- package/dist/packages/@ember/runloop/type-tests.ts/schedule.test.js +0 -39
- package/dist/packages/@ember/runloop/type-tests.ts/throttle.test.js +0 -77
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
declare module '@ember/routing/route' {
|
|
2
|
+
import EmberObject from '@ember/object';
|
|
3
|
+
import ActionHandler from '@ember/object/-private/action-handler';
|
|
4
|
+
import Transition from '@ember/routing/transition';
|
|
5
|
+
import Evented from '@ember/object/evented';
|
|
6
|
+
import { RouteQueryParam } from '@ember/routing/types';
|
|
7
|
+
import Controller from '@ember/controller';
|
|
8
|
+
|
|
9
|
+
type RouteModel = object | string | number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The `Ember.Route` class is used to define individual routes. Refer to
|
|
13
|
+
* the [routing guide](http://emberjs.com/guides/routing/) for documentation.
|
|
14
|
+
*/
|
|
15
|
+
export default class Route<
|
|
16
|
+
Model = unknown,
|
|
17
|
+
Params extends object = object
|
|
18
|
+
> extends EmberObject.extend(ActionHandler, Evented) {
|
|
19
|
+
// methods
|
|
20
|
+
/**
|
|
21
|
+
* This hook is called after this route's model has resolved. It follows
|
|
22
|
+
* identical async/promise semantics to `beforeModel` but is provided the
|
|
23
|
+
* route's resolved model in addition to the `transition`, and is therefore
|
|
24
|
+
* suited to performing logic that can only take place after the model has
|
|
25
|
+
* already resolved.
|
|
26
|
+
*
|
|
27
|
+
* @returns if the value returned from this hook is a promise, the
|
|
28
|
+
* transition will pause until the transition resolves. Otherwise,
|
|
29
|
+
* non-promise return values are not utilized in any way.
|
|
30
|
+
*/
|
|
31
|
+
afterModel(resolvedModel: Model, transition: Transition): Promise<unknown> | void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This hook is the first of the route entry validation hooks called when an
|
|
35
|
+
* attempt is made to transition into a route or one of its children. It is
|
|
36
|
+
* called before `model` and `afterModel`, and is appropriate for cases
|
|
37
|
+
* when:
|
|
38
|
+
*
|
|
39
|
+
* 1. A decision can be made to redirect elsewhere without needing to
|
|
40
|
+
* resolve the model first.
|
|
41
|
+
* 2. Any async operations need to occur first before the model is attempted
|
|
42
|
+
* to be resolved.
|
|
43
|
+
*
|
|
44
|
+
* This hook is provided the current `transition` attempt as a parameter,
|
|
45
|
+
* which can be used to `.abort()` the transition, save it for a later
|
|
46
|
+
* `.retry()`, or retrieve values set on it from a previous hook. You can
|
|
47
|
+
* also just call `this.transitionTo` to another route to implicitly abort
|
|
48
|
+
* the `transition`. You can return a promise from this hook to pause the
|
|
49
|
+
* transition until the promise resolves (or rejects). This could be useful,
|
|
50
|
+
* for instance, for retrieving async code from the server that is required
|
|
51
|
+
* to enter a route.
|
|
52
|
+
*
|
|
53
|
+
* @returns if the value returned from this hook is a promise, the
|
|
54
|
+
* transition will pause until the transition resolves. Otherwise,
|
|
55
|
+
* non-promise return values are not utilized in any way.
|
|
56
|
+
*/
|
|
57
|
+
beforeModel(transition: Transition): Promise<unknown> | void;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns the controller of the current route, or a parent (or any
|
|
61
|
+
* ancestor) route in a route hierarchy.
|
|
62
|
+
*
|
|
63
|
+
* The controller instance must already have been created, either through
|
|
64
|
+
* entering the associated route or using `generateController`.
|
|
65
|
+
*
|
|
66
|
+
* @param name the name of the route or controller
|
|
67
|
+
*/
|
|
68
|
+
controllerFor(name: string): Controller;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A hook you can implement to convert the URL into the model for
|
|
72
|
+
* this route.
|
|
73
|
+
*/
|
|
74
|
+
model(params: Params, transition: Transition): Model | PromiseLike<Model>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns the model of a parent (or any ancestor) route
|
|
78
|
+
* in a route hierarchy. During a transition, all routes
|
|
79
|
+
* must resolve a model object, and if a route
|
|
80
|
+
* needs access to a parent route's model in order to
|
|
81
|
+
* resolve a model (or just reuse the model from a parent),
|
|
82
|
+
* it can call `this.modelFor(theNameOfParentRoute)` to
|
|
83
|
+
* retrieve it.
|
|
84
|
+
*/
|
|
85
|
+
modelFor(name: string): unknown;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves parameters, for current route using the state.params
|
|
89
|
+
* variable and getQueryParamsFor, using the supplied routeName.
|
|
90
|
+
*/
|
|
91
|
+
paramsFor(name: string): object;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A hook you can implement to optionally redirect to another route.
|
|
95
|
+
*
|
|
96
|
+
* If you call `this.transitionTo` from inside of this hook, this route
|
|
97
|
+
* will not be entered in favor of the other hook.
|
|
98
|
+
*
|
|
99
|
+
* `redirect` and `afterModel` behave very similarly and are
|
|
100
|
+
* called almost at the same time, but they have an important
|
|
101
|
+
* distinction in the case that, from one of these hooks, a
|
|
102
|
+
* redirect into a child route of this route occurs: redirects
|
|
103
|
+
* from `afterModel` essentially invalidate the current attempt
|
|
104
|
+
* to enter this route, and will result in this route's `beforeModel`,
|
|
105
|
+
* `model`, and `afterModel` hooks being fired again within
|
|
106
|
+
* the new, redirecting transition. Redirects that occur within
|
|
107
|
+
* the `redirect` hook, on the other hand, will _not_ cause
|
|
108
|
+
* these hooks to be fired again the second time around; in
|
|
109
|
+
* other words, by the time the `redirect` hook has been called,
|
|
110
|
+
* both the resolved model and attempted entry into this route
|
|
111
|
+
* are considered to be fully validated.
|
|
112
|
+
*/
|
|
113
|
+
redirect(model: Model, transition: Transition): void;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Refresh the model on this route and any child routes, firing the
|
|
117
|
+
* `beforeModel`, `model`, and `afterModel` hooks in a similar fashion
|
|
118
|
+
* to how routes are entered when transitioning in from other route.
|
|
119
|
+
* The current route params (e.g. `article_id`) will be passed in
|
|
120
|
+
* to the respective model hooks, and if a different model is returned,
|
|
121
|
+
* `setupController` and associated route hooks will re-fire as well.
|
|
122
|
+
* An example usage of this method is re-querying the server for the
|
|
123
|
+
* latest information using the same parameters as when the route
|
|
124
|
+
* was first entered.
|
|
125
|
+
* Note that this will cause `model` hooks to fire even on routes
|
|
126
|
+
* that were provided a model object when the route was initially
|
|
127
|
+
* entered.
|
|
128
|
+
*/
|
|
129
|
+
refresh(): Transition;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Transition into another route while replacing the current URL, if possible.
|
|
133
|
+
* This will replace the current history entry instead of adding a new one.
|
|
134
|
+
* Beside that, it is identical to `transitionTo` in all other respects. See
|
|
135
|
+
* 'transitionTo' for additional information regarding multiple models.
|
|
136
|
+
*
|
|
137
|
+
* @param name the name of the route or a URL
|
|
138
|
+
* @param models the model(s) or identifier(s) to be used while
|
|
139
|
+
* transitioning to the route.
|
|
140
|
+
* @param options optional hash with a queryParams property
|
|
141
|
+
* containing a mapping of query parameters. May be supplied
|
|
142
|
+
* as the only parameter to trigger a query-parameter-only
|
|
143
|
+
* transition.
|
|
144
|
+
* @returns the Transition object associated with this attempted
|
|
145
|
+
* transition
|
|
146
|
+
* @deprecated until 5.0. Inject the router service and use its methods.
|
|
147
|
+
*/
|
|
148
|
+
replaceWith(name: string, ...args: unknown[]): Transition;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* A hook you can use to reset controller values either when the model
|
|
152
|
+
* changes or the route is exiting.
|
|
153
|
+
*/
|
|
154
|
+
resetController(controller: Controller, isExiting: boolean, transition: Transition): void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Sends an action to the router, which will delegate it to the currently active
|
|
158
|
+
* route hierarchy per the bubbling rules explained under actions.
|
|
159
|
+
*/
|
|
160
|
+
send(name: string, ...args: unknown[]): void;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A hook you can implement to convert the route's model into parameters
|
|
164
|
+
* for the URL.
|
|
165
|
+
*
|
|
166
|
+
* The default `serialize` method will insert the model's `id` into the
|
|
167
|
+
* route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'.
|
|
168
|
+
* If the route has multiple dynamic segments or does not contain '_id', `serialize`
|
|
169
|
+
* will return `Ember.getProperties(model, params)`
|
|
170
|
+
* This method is called when `transitionTo` is called with a context
|
|
171
|
+
* in order to populate the URL.
|
|
172
|
+
*/
|
|
173
|
+
serialize(model: Model, params: string[]): string | object;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* A hook you can use to setup the controller for the current route.
|
|
177
|
+
* This method is called with the controller for the current route and the
|
|
178
|
+
* model supplied by the `model` hook.
|
|
179
|
+
* By default, the `setupController` hook sets the `model` property of
|
|
180
|
+
* the controller to the `model`.
|
|
181
|
+
* If you implement the `setupController` hook in your Route, it will
|
|
182
|
+
* prevent this default behavior. If you want to preserve that behavior
|
|
183
|
+
* when implementing your `setupController` function, make sure to call
|
|
184
|
+
* `_super`
|
|
185
|
+
*/
|
|
186
|
+
setupController(controller: Controller, model: Model, transition: Transition): void;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Transition the application into another route. The route may
|
|
190
|
+
* be either a single route or route path:
|
|
191
|
+
*
|
|
192
|
+
* ```javascript
|
|
193
|
+
* this.transitionTo('blogPosts');
|
|
194
|
+
* this.transitionTo('blogPosts.recentEntries');
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* Optionally supply a model for the route in question. The model
|
|
198
|
+
* will be serialized into the URL using the `serialize` hook of
|
|
199
|
+
* the route:
|
|
200
|
+
*
|
|
201
|
+
* ```javascript
|
|
202
|
+
* this.transitionTo('blogPost', aPost);
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* If a literal is passed (such as a number or a string), it will
|
|
206
|
+
* be treated as an identifier instead. In this case, the `model`
|
|
207
|
+
* hook of the route will be triggered:
|
|
208
|
+
*
|
|
209
|
+
* ```javascript
|
|
210
|
+
* this.transitionTo('blogPost', 1);
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* Multiple models will be applied last to first recursively up the
|
|
214
|
+
* route tree.
|
|
215
|
+
*
|
|
216
|
+
* ```app/routes.js
|
|
217
|
+
* // ...
|
|
218
|
+
*
|
|
219
|
+
* Router.map(function() {
|
|
220
|
+
* this.route('blogPost', { path:':blogPostId' }, function() {
|
|
221
|
+
* this.route('blogComment', { path: ':blogCommentId' });
|
|
222
|
+
* });
|
|
223
|
+
* });
|
|
224
|
+
*
|
|
225
|
+
* export default Router;
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* ```javascript
|
|
229
|
+
* this.transitionTo('blogComment', aPost, aComment);
|
|
230
|
+
* this.transitionTo('blogComment', 1, 13);
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* It is also possible to pass a URL (a string that starts with a
|
|
234
|
+
* `/`).
|
|
235
|
+
*
|
|
236
|
+
* ```javascript
|
|
237
|
+
* this.transitionTo('/');
|
|
238
|
+
* this.transitionTo('/blog/post/1/comment/13');
|
|
239
|
+
* this.transitionTo('/blog/posts?sort=title');
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* An options hash with a `queryParams` property may be provided as
|
|
243
|
+
* the final argument to add query parameters to the destination URL.
|
|
244
|
+
*
|
|
245
|
+
* ```javascript
|
|
246
|
+
* this.transitionTo('blogPost', 1, {
|
|
247
|
+
* queryParams: { showComments: 'true' }
|
|
248
|
+
* });
|
|
249
|
+
*
|
|
250
|
+
* // if you just want to transition the query parameters without changing the route
|
|
251
|
+
* this.transitionTo({ queryParams: { sort: 'date' } });
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* See also [replaceWith](#method_replaceWith).
|
|
255
|
+
*
|
|
256
|
+
* Simple Transition Example
|
|
257
|
+
*
|
|
258
|
+
* ```app/routes.js
|
|
259
|
+
* // ...
|
|
260
|
+
*
|
|
261
|
+
* Router.map(function() {
|
|
262
|
+
* this.route('index');
|
|
263
|
+
* this.route('secret');
|
|
264
|
+
* this.route('fourOhFour', { path: '*:' });
|
|
265
|
+
* });
|
|
266
|
+
*
|
|
267
|
+
* export default Router;
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* ```app/routes/index.js
|
|
271
|
+
* import Route from '@ember/routing/route';
|
|
272
|
+
* import { action } from '@ember/object';
|
|
273
|
+
*
|
|
274
|
+
* export default class IndexRoute extends Route {
|
|
275
|
+
* @action
|
|
276
|
+
* moveToSecret(context) {
|
|
277
|
+
* if (authorized()) {
|
|
278
|
+
* this.transitionTo('secret', context);
|
|
279
|
+
* } else {
|
|
280
|
+
* this.transitionTo('fourOhFour');
|
|
281
|
+
* }
|
|
282
|
+
* }
|
|
283
|
+
* }
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
286
|
+
* Transition to a nested route
|
|
287
|
+
*
|
|
288
|
+
* ```app/router.js
|
|
289
|
+
* // ...
|
|
290
|
+
*
|
|
291
|
+
* Router.map(function() {
|
|
292
|
+
* this.route('articles', { path: '/articles' }, function() {
|
|
293
|
+
* this.route('new');
|
|
294
|
+
* });
|
|
295
|
+
* });
|
|
296
|
+
*
|
|
297
|
+
* export default Router;
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* ```app/routes/index.js
|
|
301
|
+
* import Route from '@ember/routing/route';
|
|
302
|
+
* import { action } from '@ember/object';
|
|
303
|
+
*
|
|
304
|
+
* export default class IndexRoute extends Route {
|
|
305
|
+
* @action
|
|
306
|
+
* transitionToNewArticle() {
|
|
307
|
+
* this.transitionTo('articles.new');
|
|
308
|
+
* }
|
|
309
|
+
* }
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* Multiple Models Example
|
|
313
|
+
*
|
|
314
|
+
* ```app/router.js
|
|
315
|
+
* // ...
|
|
316
|
+
*
|
|
317
|
+
* Router.map(function() {
|
|
318
|
+
* this.route('index');
|
|
319
|
+
*
|
|
320
|
+
* this.route('breakfast', { path: ':breakfastId' }, function() {
|
|
321
|
+
* this.route('cereal', { path: ':cerealId' });
|
|
322
|
+
* });
|
|
323
|
+
* });
|
|
324
|
+
*
|
|
325
|
+
* export default Router;
|
|
326
|
+
* ```
|
|
327
|
+
*
|
|
328
|
+
* ```app/routes/index.js
|
|
329
|
+
* import Route from '@ember/routing/route';
|
|
330
|
+
* import { action } from '@ember/object';
|
|
331
|
+
*
|
|
332
|
+
* export default class IndexRoute extends Route {
|
|
333
|
+
* @action
|
|
334
|
+
* moveToChocolateCereal() {
|
|
335
|
+
* let cereal = { cerealId: 'ChocolateYumminess' };
|
|
336
|
+
* let breakfast = { breakfastId: 'CerealAndMilk' };
|
|
337
|
+
*
|
|
338
|
+
* this.transitionTo('breakfast.cereal', breakfast, cereal);
|
|
339
|
+
* }
|
|
340
|
+
* }
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* Nested Route with Query String Example
|
|
344
|
+
*
|
|
345
|
+
* ```app/routes.js
|
|
346
|
+
* // ...
|
|
347
|
+
*
|
|
348
|
+
* Router.map(function() {
|
|
349
|
+
* this.route('fruits', function() {
|
|
350
|
+
* this.route('apples');
|
|
351
|
+
* });
|
|
352
|
+
* });
|
|
353
|
+
*
|
|
354
|
+
* export default Router;
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* ```app/routes/index.js
|
|
358
|
+
* import Route from '@ember/routing/route';
|
|
359
|
+
*
|
|
360
|
+
* export default class IndexRoute extends Route {
|
|
361
|
+
* @action
|
|
362
|
+
* transitionToApples() {
|
|
363
|
+
* this.transitionTo('fruits.apples', { queryParams: { color: 'red' } });
|
|
364
|
+
* }
|
|
365
|
+
* }
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* @param name the name of the route or a URL.
|
|
369
|
+
* @param models the model(s) or identifier(s) to be used while
|
|
370
|
+
* transitioning to the route.
|
|
371
|
+
* @param options optional hash with a queryParams property
|
|
372
|
+
* containing a mapping of query parameters. May be supplied
|
|
373
|
+
* as the only parameter to trigger a query-parameter-only
|
|
374
|
+
* transition.
|
|
375
|
+
* @returns the Transition object associated with this attempted
|
|
376
|
+
* transition
|
|
377
|
+
* @deprecated until 5.0. Inject the router service and use its methods.
|
|
378
|
+
*/
|
|
379
|
+
transitionTo(name: string, options?: { queryParams: object }): Transition;
|
|
380
|
+
transitionTo(name: string, modelsA: RouteModel, options?: { queryParams: object }): Transition;
|
|
381
|
+
transitionTo(
|
|
382
|
+
name: string,
|
|
383
|
+
modelsA: RouteModel,
|
|
384
|
+
modelsB: RouteModel,
|
|
385
|
+
options?: { queryParams: object }
|
|
386
|
+
): Transition;
|
|
387
|
+
transitionTo(
|
|
388
|
+
name: string,
|
|
389
|
+
modelsA: RouteModel,
|
|
390
|
+
modelsB: RouteModel,
|
|
391
|
+
modelsC: RouteModel,
|
|
392
|
+
options?: { queryParams: object }
|
|
393
|
+
): Transition;
|
|
394
|
+
transitionTo(
|
|
395
|
+
name: string,
|
|
396
|
+
modelsA: RouteModel,
|
|
397
|
+
modelsB: RouteModel,
|
|
398
|
+
modelsC: RouteModel,
|
|
399
|
+
modelsD: RouteModel,
|
|
400
|
+
options?: { queryParams: object }
|
|
401
|
+
): Transition;
|
|
402
|
+
transitionTo(options: { queryParams: object }): Transition;
|
|
403
|
+
|
|
404
|
+
// https://emberjs.com/api/ember/release/classes/Route/methods/intermediateTransitionTo?anchor=intermediateTransitionTo
|
|
405
|
+
/**
|
|
406
|
+
* Perform a synchronous transition into another route without attempting to resolve promises,
|
|
407
|
+
* update the URL, or abort any currently active asynchronous transitions
|
|
408
|
+
* (i.e. regular transitions caused by transitionTo or URL changes).
|
|
409
|
+
*
|
|
410
|
+
* @param name the name of the route or a URL
|
|
411
|
+
* @param models the model(s) or identifier(s) to be used while
|
|
412
|
+
* transitioning to the route.
|
|
413
|
+
* @returns the Transition object associated with this attempted transition
|
|
414
|
+
*/
|
|
415
|
+
intermediateTransitionTo(name: string, ...models: unknown[]): Transition;
|
|
416
|
+
|
|
417
|
+
// properties
|
|
418
|
+
/**
|
|
419
|
+
* The controller associated with this route.
|
|
420
|
+
*/
|
|
421
|
+
controller: Controller;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* The name of the controller to associate with this route.
|
|
425
|
+
* By default, Ember will lookup a route's controller that matches the name
|
|
426
|
+
* of the route (i.e. `App.PostController` for `App.PostRoute`). However,
|
|
427
|
+
* if you would like to define a specific controller to use, you can do so
|
|
428
|
+
* using this property.
|
|
429
|
+
* This is useful in many ways, as the controller specified will be:
|
|
430
|
+
* * p assed to the `setupController` method.
|
|
431
|
+
* * used as the controller for the view being rendered by the route.
|
|
432
|
+
* * returned from a call to `controllerFor` for the route.
|
|
433
|
+
*/
|
|
434
|
+
controllerName: string;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* The name of the route, dot-delimited, including the engine prefix if applicable.
|
|
438
|
+
*/
|
|
439
|
+
fullRouteName: string;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Configuration hash for this route's queryParams.
|
|
443
|
+
*/
|
|
444
|
+
queryParams: { [key: string]: RouteQueryParam };
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The name of the route, dot-delimited
|
|
448
|
+
*/
|
|
449
|
+
routeName: string;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* The name of the template to use by default when rendering this routes
|
|
453
|
+
* template.
|
|
454
|
+
* This is similar with `viewName`, but is useful when you just want a custom
|
|
455
|
+
* template without a view.
|
|
456
|
+
*/
|
|
457
|
+
templateName: string;
|
|
458
|
+
|
|
459
|
+
// events
|
|
460
|
+
/**
|
|
461
|
+
* This hook is executed when the router enters the route. It is not executed
|
|
462
|
+
* when the model for the route changes.
|
|
463
|
+
*/
|
|
464
|
+
activate(transition: Transition): void;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* This hook is executed when the router completely exits this route. It is
|
|
468
|
+
* not executed when the model for the route changes.
|
|
469
|
+
*/
|
|
470
|
+
deactivate(transition: Transition): void;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* The didTransition action is fired after a transition has successfully been
|
|
474
|
+
* completed. This occurs after the normal model hooks (beforeModel, model,
|
|
475
|
+
* afterModel, setupController) have resolved. The didTransition action has
|
|
476
|
+
* no arguments, however, it can be useful for tracking page views or resetting
|
|
477
|
+
* state on the controller.
|
|
478
|
+
*/
|
|
479
|
+
didTransition(): void;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* When attempting to transition into a route, any of the hooks may return a promise
|
|
483
|
+
* that rejects, at which point an error action will be fired on the partially-entered
|
|
484
|
+
* routes, allowing for per-route error handling logic, or shared error handling logic
|
|
485
|
+
* defined on a parent route.
|
|
486
|
+
*/
|
|
487
|
+
error(error: unknown, transition: Transition): void;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* The loading action is fired on the route when a route's model hook returns a
|
|
491
|
+
* promise that is not already resolved. The current Transition object is the first
|
|
492
|
+
* parameter and the route that triggered the loading event is the second parameter.
|
|
493
|
+
*/
|
|
494
|
+
loading(transition: Transition, route: Route): void;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* The willTransition action is fired at the beginning of any attempted transition
|
|
498
|
+
* with a Transition object as the sole argument. This action can be used for aborting,
|
|
499
|
+
* redirecting, or decorating the transition from the currently active routes.
|
|
500
|
+
*/
|
|
501
|
+
willTransition(transition: Transition): void;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Allows you to produce custom metadata for the route.
|
|
505
|
+
* The return value of this method will be attached to
|
|
506
|
+
* its corresponding RouteInfoWithAttributes object.
|
|
507
|
+
* Example
|
|
508
|
+
* ```app/routes/posts/index.js
|
|
509
|
+
* import Route from '@ember/routing/route';
|
|
510
|
+
* export default class PostsIndexRoute extends Route {
|
|
511
|
+
* buildRouteInfoMetadata() {
|
|
512
|
+
* return { title: 'Posts Page' }
|
|
513
|
+
* }
|
|
514
|
+
* }
|
|
515
|
+
* ```
|
|
516
|
+
* ```app/routes/application.js
|
|
517
|
+
* import Route from '@ember/routing/route';
|
|
518
|
+
* import { inject as service } from '@ember/service';
|
|
519
|
+
* export default class ApplicationRoute extends Route {
|
|
520
|
+
* @service router
|
|
521
|
+
* constructor() {
|
|
522
|
+
* super(...arguments);
|
|
523
|
+
* this.router.on('routeDidChange', transition => {
|
|
524
|
+
* document.title = transition.to.metadata.title;
|
|
525
|
+
* // would update document's title to "Posts Page"
|
|
526
|
+
* });
|
|
527
|
+
* }
|
|
528
|
+
* }
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
buildRouteInfoMetadata(): unknown;
|
|
532
|
+
}
|
|
533
|
+
}
|