refactor(ivy): combine contentQueries and contentQueriesRefresh functions (#28503)

Prior to this update we had separate contentQueries and contentQueriesRefresh functions to handle creation and update phases. This approach was inconsistent with View Queries, Host Bindings and Template functions that we generate for Component/Directive defs. Now the mentioned 2 functions are combines into one (contentQueries), creation and update logic is separated with RenderFlags (similar to what we have in other generated functions).

PR Close #28503
This commit is contained in:
Andrew Kushnir
2019-02-02 11:20:33 -08:00
committed by Miško Hevery
parent 644e7a28d8
commit 39d0311e4e
11 changed files with 206 additions and 244 deletions

View File

@ -22,9 +22,15 @@ export type ComponentTemplate<T> = {
};
/**
* Definition of what a query function should look like.
* Definition of what a view queries function should look like.
*/
export type ComponentQuery<T> = ComponentTemplate<T>;
export type ViewQueriesFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) => void;
/**
* Definition of what a content queries function should look like.
*/
export type ContentQueriesFunction<T> =
<U extends T>(rf: RenderFlags, ctx: U, directiveIndex: number) => void;
/**
* Definition of what a factory function should look like.
@ -148,14 +154,13 @@ export interface DirectiveDef<T> extends BaseDef<T> {
factory: FactoryFn<T>;
/**
* Function to create instances of content queries associated with a given directive.
* Function to create and refresh content queries associated with a given directive.
*/
contentQueries: ((directiveIndex: number) => void)|null;
contentQueries: ContentQueriesFunction<T>|null;
/** Refreshes content queries associated with directives in a given view */
contentQueriesRefresh: ((directiveIndex: number) => void)|null;
/** Refreshes host bindings on the associated directive. */
/**
* Refreshes host bindings on the associated directive.
*/
hostBindings: HostBindingsFunction<T>|null;
/* The following are lifecycle hooks for this component */
@ -236,7 +241,7 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
/**
* Query-related instructions for a component.
*/
viewQuery: ComponentQuery<T>|null;
viewQuery: ViewQueriesFunction<T>|null;
/**
* The view encapsulation type, which determines how styles are applied to

View File

@ -13,7 +13,7 @@ import {QueryList} from '../../linker';
import {Sanitizer} from '../../sanitization/security';
import {LContainer} from './container';
import {ComponentDef, ComponentQuery, ComponentTemplate, DirectiveDef, DirectiveDefList, HostBindingsFunction, PipeDef, PipeDefList} from './definition';
import {ComponentDef, ComponentTemplate, DirectiveDef, DirectiveDefList, HostBindingsFunction, PipeDef, PipeDefList, ViewQueriesFunction} from './definition';
import {I18nUpdateOpCodes, TI18n} from './i18n';
import {TElementNode, TNode, TViewNode} from './node';
import {PlayerHandler} from './player';
@ -323,7 +323,7 @@ export interface TView {
/**
* A function containing query-related instructions.
*/
viewQuery: ComponentQuery<{}>|null;
viewQuery: ViewQueriesFunction<{}>|null;
/**
* Pointer to the `TNode` that represents the root of the view.