UNPKG

6.88 kBTypeScriptView Raw
1declare module '@ember/routing/transition' {
2 /**
3 Re-exports the `Transition` type from [router.js]. `Transition`s are used in
4 Ember's `Route` hooks and `RouterService` events.
5
6 [router.js]: https://github.com/tildeio/router.js
7
8 @module @ember/routing/transition
9 */
10 /**
11 A `Transition` is a thennable (a `Promise`-like object) that represents an
12 attempt to transition to another route. It can be aborted, either explicitly
13 via `abort` or by attempting another transition while a previous one is still
14 underway. An aborted transition can also be `retry()`d later.
15
16 A `Transition` is not user-constructible; the only legal way to get one is in
17 a `Route` hook or a `RouterService.on()` callback. However, you can import the
18 type by using `import type` syntax with TypeScript or `import()` in JSDoc
19 comments.
20
21 @class Transition
22 @public
23 */
24 /**
25 The `Transition`'s internal `Promise`. Calling `.then` on this property is
26 that same as calling `.then` on the `Transition` object itself, but this
27 property is exposed for when you want to pass around a Transition's promise,
28 but not the Transition object itself, since Transition object can be
29 externally `abort`ed, while the promise cannot.
30
31 @property promise
32 @type {Promise}
33 @public
34 */
35 /**
36 Custom state can be stored on a `Transition`'s `data` object. This can be
37 useful for decorating a `Transition` within an earlier hook and shared with a
38 later hook. Properties set on `data` will be copied to new transitions
39 generated by calling `retry` on this transition.
40
41 @property data
42 @type {Object}
43 @public
44 */
45 /**
46 A standard promise hook that resolves if the `Transition` succeeds and rejects
47 if it fails/redirects/aborts.
48
49 Forwards to the internal `promise` property which you can use in situations
50 where you want to pass around a thennable, but not the `Transition` itself.
51
52 @method then
53 @param {Function} onFulfilled
54 @param {Function} onRejected
55 @param {String} label optional string for labeling the promise. Useful for
56 tooling.
57 @return {Promise}
58 @public
59 */
60 /**
61 Forwards to the internal `promise` property which you can use in situations
62 where you want to pass around a thennable, but not the `Transition` itself.
63
64 @method catch
65 @param {Function} onRejection
66 @param {String} label optional string for labeling the promise. Useful for
67 tooling.
68 @return {Promise}
69 @public
70 */
71 /**
72 Forwards to the internal `promise` property which you can use in situations
73 where you want to pass around a thennable, but not the `Transition` itself.
74
75 @method finally
76 @param {Function} callback
77 @param {String} label optional string for labeling the promise. Useful for
78 tooling.
79 @return {Promise}
80 @public
81 */
82 /**
83 Aborts the `Transition`. Note you can also implicitly abort a transition
84 by initiating another transition while a previous one is underway.
85
86 @method abort
87 @return {Transition} this transition
88 @public
89 */
90 /**
91 Retries a previously-aborted transition (making sure to abort the transition
92 if it's still active). Returns a new transition that represents the new
93 attempt to transition.
94
95 @method retry
96 @return {Transition} new transition
97 @public
98 */
99 /**
100 Sets the URL-changing method to be employed at the end of a successful
101 transition. By default, a new `Transition` will just use `updateURL`, but
102 passing 'replace' to this method will cause the URL to update using
103 'replaceWith' instead. Omitting a parameter will disable the URL change,
104 allowing for transitions that don't update the URL at completion (this is also
105 used for handleURL, since the URL has already changed before the transition
106 took place).
107
108 @method method
109 @param {String} method the type of URL-changing method to use at the end of a
110 transition. Accepted values are 'replace', falsy values, or any other
111 non-falsy value (which is interpreted as an updateURL transition).
112
113 @return {Transition} this transition
114 @public
115 */
116 /**
117
118 Fires an event on the current list of resolved/resolving handlers within this
119 transition. Useful for firing events on route hierarchies that haven't fully
120 been entered yet.
121
122 Note: This method is also aliased as `send`
123
124 @method trigger
125 @param {Boolean} [ignoreFailure=false] a boolean specifying whether unhandled
126 events throw an error
127 @param {String} name the name of the event to fire
128 @public
129 */
130 /**
131 * This property is a `RouteInfo` object that represents where the router is
132 * transitioning to. It's important to note that a `RouteInfo` is a linked list
133 * and this property represents the leafmost route.
134 * @property {null|RouteInfo|RouteInfoWithAttributes} to
135 * @public
136 */
137 /**
138 * This property is a `RouteInfo` object that represents where transition
139 * originated from. It's important to note that a `RouteInfo` is a linked list
140 * and this property represents the head node of the list. In the case of an
141 * initial render, `from` will be set to `null`.
142 * @property {null|RouteInfoWithAttributes} from
143 * @public
144 */
145 /**
146 Transitions are aborted and their promises rejected when redirects occur; this
147 method returns a promise that will follow any redirects that occur and fulfill
148 with the value fulfilled by any redirecting transitions that occur.
149
150 @method followRedirects
151 @return {Promise} a promise that fulfills with the same value that the final
152 redirecting transition fulfills with
153 @public
154 */
155 /**
156 In non-production builds, this function will return the stack that this
157 `Transition` was created within. In production builds, this function will not
158 be present.
159
160 @method debugCreationStack
161 @return string
162 */
163 /**
164 In non-production builds, this function will return the stack that this
165 `Transition` was aborted within (or `undefined` if the `Transition` has not
166 been aborted yet). In production builds, this function will not be present.
167
168 @method debugAbortStack
169 @return string
170 */
171 /**
172 In non-production builds, this property references the `Transition` that
173 _this_ `Transition` was derived from or `undefined` if this transition did not
174 derive from another. In production builds, this property will not be present.
175
176 @property debugPreviousTransition
177 @type {Transition | undefined}
178 */
179 export type { Transition as default } from 'router_js';
180}