|
2 | 2 | * @coreapi |
3 | 3 | * @module view |
4 | 4 | */ /** for typedoc */ |
5 | | -import { equals, applyPairs, removeFrom, TypedMap, inArray } from '../common/common'; |
| 5 | +import { equals, applyPairs, removeFrom, TypedMap, inArray, find } from '../common/common'; |
6 | 6 | import { curry, prop } from '../common/hof'; |
7 | 7 | import { isString, isArray } from '../common/predicates'; |
8 | 8 | import { trace } from '../common/trace'; |
9 | 9 | import { PathNode } from '../path/pathNode'; |
10 | 10 | import { ActiveUIView, ViewContext, ViewConfig } from './interface'; |
11 | 11 | import { _ViewDeclaration } from '../state/interface'; |
| 12 | +import { UIRouter } from '../router'; |
12 | 13 |
|
13 | 14 | export type ViewConfigFactory = (path: PathNode[], decl: _ViewDeclaration) => ViewConfig | ViewConfig[]; |
14 | 15 |
|
15 | 16 | export interface ViewServicePluginAPI { |
16 | 17 | _rootViewContext(context?: ViewContext): ViewContext; |
17 | 18 | _viewConfigFactory(viewType: string, factory: ViewConfigFactory); |
| 19 | + /** @param id router.$id + "." + uiView.id */ |
| 20 | + _registeredUIView(id: string): ActiveUIView; |
18 | 21 | _registeredUIViews(): ActiveUIView[]; |
19 | 22 | _activeViewConfigs(): ViewConfig[]; |
20 | 23 | _onSync(listener: ViewSyncListener): Function; |
@@ -56,6 +59,7 @@ export class ViewService { |
56 | 59 | public _pluginapi: ViewServicePluginAPI = { |
57 | 60 | _rootViewContext: this._rootViewContext.bind(this), |
58 | 61 | _viewConfigFactory: this._viewConfigFactory.bind(this), |
| 62 | + _registeredUIView: (id: string) => find(this._uiViews, view => `${this.router.$id}.${view.id}` === id), |
59 | 63 | _registeredUIViews: () => this._uiViews, |
60 | 64 | _activeViewConfigs: () => this._viewConfigs, |
61 | 65 | _onSync: (listener: ViewSyncListener) => { |
@@ -187,7 +191,7 @@ export class ViewService { |
187 | 191 | return { uiViewName, uiViewContextAnchor }; |
188 | 192 | } |
189 | 193 |
|
190 | | - constructor() {} |
| 194 | + constructor(private router: UIRouter) {} |
191 | 195 |
|
192 | 196 | private _rootViewContext(context?: ViewContext): ViewContext { |
193 | 197 | return (this._rootContext = context || this._rootContext); |
|
0 commit comments