UNPKG

4.5 kBTypeScriptView Raw
1declare module '@ember/routing/route-info' {
2 /**
3 Re-exports the `RouteInfo` and `RouteInfoWithMetadata` types from [router.js].
4 `RouteInfo` and `RouteInfoWithMetadata` appear as properties on `Transition`
5 instances.
6
7 [router.js]: https://github.com/tildeio/router.js
8
9 @module @ember/routing/route-info
10 */
11 /**
12 A `RouteInfo` is an object that contains metadata about a specific route
13 within a `Transition`. It is read-only and internally immutable. It is also
14 not observable, because a `Transition` instance is never changed after
15 creation.
16
17 A `RouteInfo` is not user-constructible; the only legal way to get one is from
18 a valid `Transition`. However, you can import the type by using `import type`
19 syntax with TypeScript or `import()` in JSDoc comments.
20
21 @class RouteInfo
22 @public
23 */
24 /**
25 The dot-separated, fully-qualified name of the route, like `"people.index"`.
26 @property {String} name
27 @public
28 */
29 /**
30 The final segment of the fully-qualified name of the route, like `"index"`
31 @property {String} localName
32 @public
33 */
34 /**
35 The values of the route's parameters. These are the same params that are
36 received as arguments to the route's `model` hook. Contains only the
37 parameters valid for this route, if any (params for parent or child routes are
38 not merged).
39 @property {Object} params
40 @public
41 */
42 /**
43 The ordered list of the names of the params required for this route. It will
44 contain the same strings as Object.keys(params), but here the order is
45 significant. This allows users to correctly pass params into routes
46 programmatically.
47 @property {Array} paramNames
48 @public
49 */
50 /**
51 The values of any queryParams on this route.
52 @property {Object} queryParams
53 @public
54 */
55 /**
56 Will contain the result `Route#buildRouteInfoMetadata` for the corresponding
57 Route.
58 @property {Any} metadata
59 @public
60 */
61 /**
62 A reference to the parent route's `RouteInfo`. This can be used to traverse
63 upward to the topmost `RouteInfo`.
64 @property {RouteInfo|null} parent
65 @public
66 */
67 /**
68 A reference to the child route's `RouteInfo`. This can be used to traverse
69 downward to the leafmost `RouteInfo`.
70 @property {RouteInfo|null} child
71 @public
72 */
73 /**
74 Allows you to traverse through the linked list of `RouteInfo`s from the
75 topmost to leafmost. Returns the first `RouteInfo` in the linked list for
76 which the callback returns true.
77
78 This method is similar to the `find()` method defined in ECMAScript 2015.
79
80 The callback method you provide should have the following signature (all
81 parameters are optional):
82
83 ```javascript
84 function(item, index, array);
85 ```
86
87 - `item` is the current item in the iteration.
88 - `index` is the current index in the iteration.
89 - `array` is the array itself.
90
91 It should return the `true` to include the item in the results, `false`
92 otherwise.
93
94 Note that in addition to a callback, you can also pass an optional target
95 object that will be set as `this` on the context.
96
97 @method find
98 @param {Function} callback the callback to execute
99 @param {Object} [target*] optional target to use
100 @returns {Object} Found item or undefined
101 @public
102 */
103 /**
104 A `RouteInfoWithAttributes` is an object that contains metadata, including the
105 resolved value from the routes `model` hook. Like `RouteInfo`, a
106 `RouteInfoWithAttributes` represents a specific route within a Transition. It
107 is read-only and internally immutable. It is also not observable, because a
108 Transition instance is never changed after creation.
109
110 A `RouteInfoWithAttributes` is not user-constructible; the only legal way to
111 get one is from a valid `Transition`. However, you can import the type by
112 using `import type` syntax with TypeScript or `import()` in JSDoc comments.
113
114 @class RouteInfoWithAttributes
115 @extends RouteInfo
116 @public
117 */
118 /**
119 This is the resolved return value from the
120 route's model hook.
121 @property {Object|Array|String|undefined} attributes
122 @public
123 */
124 export type {
125 RouteInfo as default,
126 RouteInfoWithAttributes,
127 } from '@ember/routing/lib/route-info';
128}