@@ -521,26 +521,28 @@ export interface StateDeclaration {
521
521
onExit ?: TransitionStateHookFn ;
522
522
523
523
/**
524
- * A function which lazy loads the state (and child states )
524
+ * A function which lazy loads the state definition (and child state definitions )
525
525
*
526
526
* A state which has a `lazyLoad` function is treated as a **temporary
527
527
* placeholder** for a state definition that will be lazy loaded some time
528
528
* in the future.
529
529
* These temporary placeholder states are called "**Future States**".
530
530
*
531
531
*
532
- * ### Future State placeholders
533
- *
534
532
* #### `lazyLoad`:
535
533
*
536
- * A future state's `lazyLoad` function should return a Promise for an array of
537
- * lazy loaded [[StateDeclaration]] objects.
534
+ * A future state's `lazyLoad` function should return a Promise to lazy load the
535
+ * code for one or more lazy loaded [[StateDeclaration]] objects.
536
+ *
537
+ * If the promise resolves to an object with a `states: []` array,
538
+ * the lazy loaded states will be registered with the [[StateRegistry]].
539
+ * Generally, of the lazy loaded states should have the same name as the future state;
540
+ * then it will **replace the future state placeholder** in the registry.
538
541
*
539
- * The lazy loaded states are registered with the [[StateRegistry]].
540
- * One of the lazy loaded states must have the same name as the future state;
541
- * it will **replace the future state placeholder** in the registry.
542
+ * In any case, when the promise successfully resolves, the placeholder Future State will be deregistered.
542
543
*
543
544
* #### `url`
545
+ *
544
546
* A future state's `url` property acts as a wildcard.
545
547
*
546
548
* UI-Router matches all paths that begin with the `url`.
@@ -553,22 +555,10 @@ export interface StateDeclaration {
553
555
* It matches any state name that starts with the `name`.
554
556
* UI-Router effectively matches the future state using a `.**` [[Glob]] appended to the `name`.
555
557
*
556
- * ---
557
- *
558
- * Future state placeholders should only define `lazyLoad`, `name`, and `url`.
559
- * Any additional properties should only be defined on the state that will eventually be lazy loaded.
560
- *
561
558
* @example
562
559
* #### states.js
563
560
* ```js
564
561
*
565
- * // The parent state is not lazy loaded
566
- * {
567
- * name: 'parent',
568
- * url: '/parent',
569
- * component: ParentComponent
570
- * }
571
- *
572
562
* // This child state is a lazy loaded future state
573
563
* // The `lazyLoad` function loads the final state definition
574
564
* {
@@ -598,11 +588,18 @@ export interface StateDeclaration {
598
588
* }
599
589
* };
600
590
*
601
- * // The future state's lazyLoad imports this array of states
602
- * export default [ childState ];
591
+ * // This array of states will be registered by the lazyLoad hook
592
+ * let result = {
593
+ * states: [ childState ]
594
+ * };
595
+ *
596
+ * export default result;
603
597
* ```
604
598
*
605
599
* @param transition the [[Transition]] that is activating the future state
600
+ * @return a Promise to load the states.
601
+ * Optionally, if the promise resolves to a [[LazyLoadResult]],
602
+ * the states will be registered with the [[StateRegistry]].
606
603
*/
607
604
lazyLoad ?: ( transition : Transition ) => Promise < LazyLoadResult > ;
608
605
0 commit comments