UNPKG

1.99 kBTypeScriptView Raw
1import { _ViewDeclaration } from '../state/interface';
2import { PathNode } from '../path/pathNode';
3/** The context ref can be anything that has a `name` and a `parent` reference to another IContextRef */
4export interface ViewContext {
5 name: string;
6 parent: ViewContext;
7}
8export interface ActiveUIView {
9 /** type of framework, e.g., "ng1" or "ng2" */
10 $type: string;
11 /** An auto-incremented id */
12 id: number;
13 /** The ui-view short name */
14 name: string;
15 /** The ui-view's fully qualified name */
16 fqn: string;
17 /** The ViewConfig that is currently loaded into the ui-view */
18 config: ViewConfig;
19 /** The state context in which the ui-view tag was created. */
20 creationContext: ViewContext;
21 /** A callback that should apply a ViewConfig (or clear the ui-view, if config is undefined) */
22 configUpdated: (config: ViewConfig) => void;
23}
24/**
25 * This interface represents a [[_ViewDeclaration]] that is bound to a [[PathNode]].
26 *
27 * A `ViewConfig` is the runtime definition of a single view.
28 *
29 * During a transition, `ViewConfig`s are created for each [[_ViewDeclaration]] defined on each "entering" [[StateObject]].
30 * Then, the [[ViewService]] finds any matching `ui-view`(s) in the DOM, and supplies the ui-view
31 * with the `ViewConfig`. The `ui-view` then loads itself using the information found in the `ViewConfig`.
32 *
33 * A `ViewConfig` if matched with a `ui-view` by finding all `ui-view`s which were created in the
34 * context named by the `uiViewContextAnchor`, and finding the `ui-view` or child `ui-view` that matches
35 * the `uiViewName` address.
36 */
37export interface ViewConfig {
38 $id: number;
39 /** The normalized view declaration from [[State.views]] */
40 viewDecl: _ViewDeclaration;
41 /** The node the ViewConfig is bound to */
42 path: PathNode[];
43 loaded: boolean;
44 /** Fetches templates, runs dynamic (controller|template)Provider code, lazy loads Components, etc */
45 load(): Promise<ViewConfig>;
46}