@@ -385,131 +385,6 @@ export interface StateDeclaration {
385385 * ```
386386 */
387387 parent ?: string | StateDeclaration ;
388- /**
389- * Resolve - a mechanism to asynchronously fetch data, participating in the Transition lifecycle
390- *
391- * The `resolve:` property defines data (or other dependencies) to be fetched asynchronously when the state is being entered.
392- * After the data is fetched, it may be used in views, transition hooks or other resolves that belong to this state.
393- * The data may also be used in any views or resolves that belong to nested states.
394- *
395- * ### As an array
396- *
397- * Each array element should be a [[ResolvableLiteral]] object.
398- *
399- * #### Example:
400- * The `user` resolve injects the current `Transition` and the `UserService` (using its token, which is a string).
401- * The [[ResolvableLiteral.resolvePolicy]] sets how the resolve is processed.
402- * The `user` data, fetched asynchronously, can then be used in a view.
403- * ```js
404- * var state = {
405- * name: 'user',
406- * url: '/user/:userId
407- * resolve: [
408- * {
409- * token: 'user',
410- * policy: { when: 'EAGER' },
411- * deps: ['UserService', Transition],
412- * resolveFn: (userSvc, trans) => userSvc.fetchUser(trans.params().userId) },
413- * }
414- * ]
415- * }
416- * ```
417- *
418- * Note: an Angular 2 style [`useFactory` provider literal](https://angular.io/docs/ts/latest/cookbook/dependency-injection.html#!#provide)
419- * may also be used. See [[ProviderLike]].
420- * #### Example:
421- * ```
422- * resolve: [
423- * { provide: 'token', useFactory: (http) => http.get('/'), deps: [ Http ] },
424- * ]
425- * ```
426- *
427- * ### As an object
428- *
429- * The `resolve` property may be an object where:
430- * - Each key (string) is the name of the dependency.
431- * - Each value (function) is an injectable function which returns the dependency, or a promise for the dependency.
432- *
433- * This style is based on AngularTS injectable functions, but can be used with any UI-Router implementation.
434- * If your code will be minified, the function should be ["annotated" in the AngularTS manner](https://docs.angularjs.org/guide/di#dependency-annotation).
435- *
436- * #### AngularTS Example:
437- * ```js
438- * resolve: {
439- * // If you inject `myStateDependency` into a controller, you'll get "abc"
440- * myStateDependency: function() {
441- * return "abc";
442- * },
443- * // Dependencies are annotated in "Inline Array Annotation"
444- * myAsyncData: ['$http', '$transition$' function($http, $transition$) {
445- * // Return a promise (async) for the data
446- * return $http.get("/foos/" + $transition$.params().foo);
447- * }]
448- * }
449- * ```
450- *
451- * Note: You cannot specify a policy for each Resolvable, nor can you use non-string
452- * tokens when using the object style `resolve:` block.
453- *
454- * ### Lifecycle
455- *
456- * Since a resolve function can return a promise, the router will delay entering the state until the promises are ready.
457- * If any of the promises are rejected, the Transition is aborted with an Error.
458- *
459- * By default, resolves for a state are fetched just before that state is entered.
460- * Note that only states which are being *entered* during the `Transition` have their resolves fetched.
461- * States that are "retained" do not have their resolves re-fetched.
462- *
463- * If you are currently in a parent state `parent` and are transitioning to a child state `parent.child`, the
464- * previously resolved data for state `parent` can be injected into `parent.child` without delay.
465- *
466- * Any resolved data for `parent.child` is retained until `parent.child` is exited, e.g., by transitioning back to the `parent` state.
467- *
468- * Because of this scoping and lifecycle, resolves are a great place to fetch your application's primary data.
469- *
470- * ### Injecting resolves into other things
471- *
472- * During a transition, Resolve data can be injected into:
473- *
474- * - Views (the components which fill a `ui-view` tag)
475- * - Transition Hooks
476- * - Other resolves (a resolve may depend on asynchronous data from a different resolve)
477- *
478- * ### Injecting other things into resolves
479- *
480- * Resolve functions usually have dependencies on some other API(s).
481- * The dependencies are usually declared and injected into the resolve function.
482- * A common pattern is to inject a custom service such as `UserService`.
483- * The resolve then delegates to a service method, such as `UserService.list()`;
484- *
485- * #### Special injectable tokens
486- *
487- * - `UIRouter`: The [[UIRouter]] instance which has references to all the UI-Router services.
488- * - `Transition`: The current [[Transition]] object; information and API about the current transition, such as
489- * "to" and "from" State Parameters and transition options.
490- * - `'$transition$'`: A string alias for the `Transition` injectable
491- * - `'$state$'`: For `onEnter`/`onExit`/`onRetain`, the state being entered/exited/retained.
492- * - Other resolve tokens: A resolve can depend on another resolve, either from the same state, or from any parent state.
493- *
494- * #### Example:
495- * ```js
496- * // Injecting a resolve into another resolve
497- * resolve: [
498- * // Define a resolve 'allusers' which delegates to the UserService.list()
499- * // which returns a promise (async) for all the users
500- * { provide: 'allusers', useFactory: (UserService) => UserService.list(), deps: [UserService] },
501- *
502- * // Define a resolve 'user' which depends on the allusers resolve.
503- * // This resolve function is not called until 'allusers' is ready.
504- * { provide: 'user', (allusers, trans) => _.find(allusers, trans.params().userId, deps: ['allusers', Transition] }
505- * }
506- * ```
507- */
508- resolve ?:
509- | ResolveTypes [ ]
510- | {
511- [ key : string ] : Injectable < any > ;
512- } ;
513388 /**
514389 * Sets the resolve policy defaults for all resolves on this state
515390 *
@@ -928,6 +803,30 @@ export interface StateDeclaration {
928803 */
929804 reloadOnSearch ?: boolean ;
930805}
806+ /**
807+ * Represents a fully built StateObject, after registration in the StateRegistry
808+ * and application of all StateBuilder decorators.
809+ */
810+ export interface BuiltStateDeclaration extends StateDeclaration {
811+ /** Reference to the original StateDeclaration */
812+ self : StateDeclaration ;
813+ /** Array of Resolvables built from the resolve / resolvePolicy */
814+ resolvables : Resolvable [ ] ;
815+ /** Full path from root down to this state */
816+ path : BuiltStateDeclaration [ ] ;
817+ /** Fast lookup of included states for $state.includes() */
818+ includes : Record < string , boolean > ;
819+ /** Closest ancestor state that has a URL (navigable) */
820+ navigable ?: BuiltStateDeclaration | null ;
821+ /** URL object built from url / parent / root */
822+ url ?: any ;
823+ /** Computed parameters of this state */
824+ params ?: Record < string , any > ;
825+ /** Optional parent state */
826+ parent ?: BuiltStateDeclaration | null ;
827+ /** Optional inherited data */
828+ data ?: any ;
829+ }
931830/**
932831 * The return type of a [[StateDeclaration.lazyLoad]] function
933832 *
0 commit comments