ViewService pairs existing ui-view components (in the DOM) with view configurations from state declarations.
Overview
- Registering
ui-viewcomponents as they appear in the DOM - Activating view configs when states are entered
- Deactivating view configs when states are exited
- Synchronizing (pairing)
ui-viewcomponents with their matching view configs
Methods
registerUIView()
Registers aui-view component.
uiView- The ui-view metadata
ui-view component is created, it calls this method to register itself. After registration, the sync() method configures all ui-view components with their proper ViewConfig.
Example:
sync()
Synchronizes ui-views with view configs.ui-view components with matching ViewConfig objects. It is called automatically when:
- A ui-view is registered/deregistered
- View configs are activated/deactivated
activateViewConfig()
Activates a ViewConfig.viewConfig- The ViewConfig to activate
sync(), the view config will be paired with a matching ui-view.
deactivateViewConfig()
Deactivates a ViewConfig.viewConfig- The ViewConfig to deactivate
sync(), the view config will be un-paired from any ui-view with which it was paired.
createViewConfig()
Creates view configs from a view declaration.path- The path of nodesdecl- The view declaration
available()
Returns the list of views currently available on the page.active()
Returns the list of views containing loaded content.Static Methods
normalizeUIViewTarget()
Normalizes a view’s name from a state.views configuration.context- The context object (state declaration) that the view belongs torawViewName- The name of the view as declared inStateDeclaration.views(optional)
uiViewName and uiViewContextAnchor.
This should be used by framework implementations to calculate the values for _ViewDeclaration.$uiViewName and _ViewDeclaration.$uiViewContextAnchor.
Example:
matches()
Determines if a ui-view and ViewConfig match.uiViewsByFqn- Map of ui-views by fully-qualified nameuiView- The ui-view to match
true if a ViewConfig matches the ui-view.
ActiveUIView Interface
Represents a registeredui-view component:
ViewConfig Interface
Represents a view configuration from a state:View Matching Algorithm
The ViewService matches ui-views with view configs using:- Type matching: The ui-view’s
$typemust match the ViewConfig’s type - Name matching: The view name and context anchor must match
- Depth sorting: If multiple configs match, the deepest child wins