refactor(ivy): introduce a firstUpdatePass
flag for TView
instances (#31270)
This patch introduces a `firstUpdatePass` flag which can be used inside of instruction code to determine if this is the first time each instruction is running inside of the update block of a template or a hostBindings function. PR Close #31270
This commit is contained in:
@ -86,6 +86,7 @@ export const TViewConstructor = class TView implements ITView {
|
||||
public expandoStartIndex: number, //
|
||||
public expandoInstructions: ExpandoInstructions|null, //
|
||||
public firstTemplatePass: boolean, //
|
||||
public firstUpdatePass: boolean, //
|
||||
public staticViewQueries: boolean, //
|
||||
public staticContentQueries: boolean, //
|
||||
public preOrderHooks: HookData|null, //
|
||||
|
@ -463,6 +463,9 @@ export function refreshView<T>(
|
||||
}
|
||||
|
||||
} finally {
|
||||
if (tView.firstUpdatePass === true) {
|
||||
tView.firstUpdatePass = false;
|
||||
}
|
||||
lView[FLAGS] &= ~(LViewFlags.Dirty | LViewFlags.FirstLViewPass);
|
||||
leaveViewProcessExit();
|
||||
}
|
||||
@ -609,6 +612,7 @@ export function createTView(
|
||||
initialViewLength, // expandoStartIndex: number,
|
||||
null, // expandoInstructions: ExpandoInstructions|null,
|
||||
true, // firstTemplatePass: boolean,
|
||||
true, // firstUpdatePass: boolean,
|
||||
false, // staticViewQueries: boolean,
|
||||
false, // staticContentQueries: boolean,
|
||||
null, // preOrderHooks: HookData|null,
|
||||
@ -640,6 +644,7 @@ export function createTView(
|
||||
expandoStartIndex: initialViewLength,
|
||||
expandoInstructions: null,
|
||||
firstTemplatePass: true,
|
||||
firstUpdatePass: true,
|
||||
staticViewQueries: false,
|
||||
staticContentQueries: false,
|
||||
preOrderHooks: null,
|
||||
|
@ -363,6 +363,9 @@ export interface TView {
|
||||
/** Whether or not this template has been processed. */
|
||||
firstTemplatePass: boolean;
|
||||
|
||||
/** Whether or not the first update for this element has been processed. */
|
||||
firstUpdatePass: boolean;
|
||||
|
||||
/** Static data equivalent of LView.data[]. Contains TNodes, PipeDefInternal or TI18n. */
|
||||
data: TData;
|
||||
|
||||
|
Reference in New Issue
Block a user