import { Subscription, OperatorFunction } from 'rxjs'; import { ViewManagerEvent } from './ViewManager'; import { ViewQueryConfig, ViewQueryReadType, ViewLinkerMetadata, ViewInsertConfig, ViewResolveConfig, ViewQueryReadOptions } from './common'; /** * This service wires up a class instance with custom behavior for dealing with communication * between multiple views. The instance is usually decorated with decorators that describe the * actions needing to be performed. Such actions are resolving a view, inserting {@link Renderable}s into * the current layout, or querying for specific views and interacting with them. * * Due to the async nature of component resolution, it is important to never store the component instances * as they could change over the course of the layouts lifecycle. This is why we set up a `ViewResolve` to * get the component we want. * @export * @class ViewLinker * @example * * class MyController { * @ViewResolve({ token: SomeOtherComponent }) * getSomeOtherComponent: Observable; * * @ViewQuery({ token: MyComponent }) * onMyViewResolved(component: MyComponent): void { * // MyComponent has stream for selecting something. * component.somethingSelected.subscribe(thing => { * // When MyComponent selected something, set it on SomeOtherComponent. * this.getSomeOtherComponent().subscribe(otherComp => { * otherComp.setSomething(thing); * }); * }); * } * } * * // Lets assume I have the viewLinker instance from the root layout I'm working with. * * const myController = new MyController(); * * viewLinker.autowire(myController); */ export declare class ViewLinker { private _viewManager; private _injector; private _manipulator; /** * Wires all types of custom behavior for linker * @param {object} instance * @returns {Subscription} A subscription for all streams created. */ autowire(instance: object): Subscription; /** * Wires a query on the instance using the provided config. * @param {object} instance * @param {ViewQueryConfig} config * @returns {Subscription} */ wireQuery(instance: object, config: ViewQueryConfig): Subscription; /** * Wires a view insert on the instance using the provided config. * @param {object} instance * @param {ViewInsertConfig} config */ wireInsert(instance: object, config: ViewInsertConfig): void; /** * Wires a resolve method with the given config. * @param {object} instance * @param {ViewResolveConfig} config */ wireResolve(instance: object, config: ViewResolveConfig): void; /** * Reads metadata from a class instance. * @param {object} instance * @returns {ViewLinkerMetadata} */ readInstanceMetadata(instance: object): ViewLinkerMetadata; /** * Reads a query observable from the view manager. A `ViewQuery` decorated method can be given a different * argument depending on how you need to interact with the view. If we need the component then the * query will wait until the component is in a ready state. If we need the {@link ViewContainer} then it * will be given to us regardless of whether the component is ready or not. We can also request the query * observable instead if we want some custom resolution logic. * @template T * @param {Observable>} query * @param {(ViewQueryReadType|ViewQueryReadOptions)} [options] * @returns {Observable} */ readQuery(options?: ViewQueryReadType | ViewQueryReadOptions): OperatorFunction, any>; /** * Gets metadata for a target including merging of extension metadata. * @param {(object | null)} target * @returns {ViewLinkerMetadata} */ getMetadata(target: object | null): ViewLinkerMetadata; /** * Merges multiple metadata objects into one. The last item takes priority. * @param {...ViewLinkerMetadata[]} metadata * @returns {ViewLinkerMetadata} */ mergeMetadata(...metadata: ViewLinkerMetadata[]): ViewLinkerMetadata; private _insert; private _resolve; static readMetadata(target: any): ViewLinkerMetadata; static resolveQueryReadType(arg: ViewQueryReadType | ViewQueryReadOptions): ViewQueryReadType | undefined; }