From bf41e954814d86dbffa3fe695341d96014540617 Mon Sep 17 00:00:00 2001 From: Vidhya Pria Arunkumar Date: Thu, 14 Sep 2023 11:23:43 +0200 Subject: [PATCH] Refactored version of Observed Property Change-Id: I47f1df970ce26167c190e083ffb5b79d884949cc Signed-off-by: Vidhya Pria Arunkumar --- .../declarative_frontend/engine/stateMgmt.js | 104 +++++------------- .../src/lib/common/observed_object.ts | 4 +- .../partial_update/pu_observed_property.ts | 10 +- .../pu_observed_property_abstract.ts | 29 ++--- .../pu_synced_property_object_nested.ts | 15 +-- .../pu_synced_property_one_way.ts | 29 +---- .../pu_synced_property_two_way.ts | 25 +---- .../src/lib/partial_update/pu_types_events.ts | 1 - .../src/lib/partial_update/pu_view.ts | 16 ++- 9 files changed, 66 insertions(+), 167 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/engine/stateMgmt.js b/frameworks/bridge/declarative_frontend/engine/stateMgmt.js index 53ad13d9b57..802d32ae170 100644 --- a/frameworks/bridge/declarative_frontend/engine/stateMgmt.js +++ b/frameworks/bridge/declarative_frontend/engine/stateMgmt.js @@ -1980,8 +1980,8 @@ class SubscribableHandler { var owningProperty = SubscriberManager.Find(subscribedId); if (owningProperty) { // PU code path - if ('objectPropertyHasBeenReadPU' in owningProperty) { - owningProperty.objectPropertyHasBeenReadPU(this, propName); + if ('recordDependentUpdate' in owningProperty) { + owningProperty.recordDependentUpdate(); } } }); @@ -3361,22 +3361,7 @@ class ObservedPropertyAbstractPU extends ObservedPropertyAbstract { } notifyPropertyRead() { stateMgmtConsole.error(`${this.debugInfo()}: notifyPropertyRead, DO NOT USE with PU. Use \ - notifyPropertyHasBeenReadPU`); - } - notifyPropertyHasBeenReadPU() { - - this.subscriberRefs_.forEach((subscriber) => { - if (subscriber) { - // TODO - // propertyHasBeenReadPU is not use in the code - // defined by interface that is not used either: PropertyReadEventListener - // Maybe compiler generated code has it? - if ('propertyHasBeenReadPU' in subscriber) { - subscriber.propertyHasBeenReadPU(this); - } - } - }); - this.recordDependentUpdate(); + recordDependentUpdate`); } notifyPropertyHasChangedPU() { @@ -3473,6 +3458,9 @@ class ObservedPropertyAbstractPU extends ObservedPropertyAbstract { * and add this component to the list of components who are dependent on this property */ recordDependentUpdate() { + if (this.owningView_ && !this.owningView_.isRenderInProgress()) { + return; + } const elmtId = ViewStackProcessor.GetElmtIdToAccountFor(); if (elmtId < 0) { // not access recording @@ -3481,6 +3469,10 @@ class ObservedPropertyAbstractPU extends ObservedPropertyAbstract { this.dependentElementIds_.add(elmtId); } + objectPropertyHasChangedPU(sourceObject, changedPropertyName) { + + this.notifyPropertyHasChangedPU(); + } purgeDependencyOnElmtId(rmElmtId) { this.dependentElementIds_.delete(rmElmtId); @@ -3578,10 +3570,6 @@ class ObservedPropertyPU extends ObservedPropertyAbstractPU { this.notifyPropertyHasChangedPU(); } - objectPropertyHasBeenReadPU(souceObject, changedPropertyName) { - - this.notifyPropertyHasBeenReadPU(); - } unsubscribeWrappedObject() { if (this.wrappedValue_) { if (this.wrappedValue_ instanceof SubscribableAbstract) { @@ -3603,6 +3591,7 @@ class ObservedPropertyPU extends ObservedPropertyAbstractPU { return false; } if (!this.checkIsSupportedValue(newValue)) { + stateMgmtConsole.applicationError(`ObservedPropertyObjectPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); return false; } this.unsubscribeWrappedObject(); @@ -3629,7 +3618,7 @@ class ObservedPropertyPU extends ObservedPropertyAbstractPU { } get() { - this.notifyPropertyHasBeenReadPU(); + this.recordDependentUpdate(); return this.wrappedValue_; } getUnmonitored() { @@ -3700,18 +3689,11 @@ class ObservedPropertySimplePU extends ObservedPropertyPU { * rhs can be ObservedObject because of @Observed decoration or now * notifyPropertyHasChangedPU * - * 2- local ObservedObject member property change - * objectPropertyHasChangedPU called, eventSource is the ObservedObject stored in localCopyObservedObject_ - * no need to copy, notifyPropertyHasChangedPU - * - * 3- Rerender of the custom component triggered from the parent + * 2- Rerender of the custom component triggered from the parent * reset() is called (code generated by the transpiler), set the value of source_ , if that causes a change will call syncPeerHasChanged * syncPeerHasChanged need to deep copy the ObservedObject from source to localCopyObservedObject_ * notifyPropertyHasChangedPU * - * 4- source_ ObservedObject member property change - * objectPropertyHasChangedPU called, eventSource is the ObservedObject stored source_.getUnmonitored - * notifyPropertyHasChangedPU */ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU { constructor(source, owningChildView, thisPropertyName) { @@ -3780,19 +3762,6 @@ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU { stateMgmtConsole.warn(`${this.debugInfo()}: syncPeerHasChanged: from peer '${eventSource === null || eventSource === void 0 ? void 0 : eventSource.debugInfo()}', Unexpected situation. syncPeerHasChanged from different sender than source_. Ignoring event.`); } } - /** - * event emited by wrapped ObservedObject, when one of its property values changes - * @param souceObject - * @param changedPropertyName - */ - objectPropertyHasChangedPU(sourceObject, changedPropertyName) { - - this.notifyPropertyHasChangedPU(); - } - objectPropertyHasBeenReadPU(sourceObject, changedPropertyName) { - - this.notifyPropertyHasBeenReadPU(); - } getUnmonitored() { // unmonitored get access , no call to notifyPropertyRead ! @@ -3800,7 +3769,7 @@ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU { } get() { - this.notifyPropertyHasBeenReadPU(); + this.recordDependentUpdate(); return this.localCopyObservedObject_; } // assignment to local variable in the form of this.aProp = @@ -3834,6 +3803,7 @@ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU { // note: We can not test for newObservedObjectValue == this.localCopyObservedObject_ // here because the object might still be the same, but some property of it has changed if (!this.checkIsSupportedValue(newObservedObjectValue)) { + stateMgmtConsole.applicationError(`SynchedPropertyOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); return; } // unsubscribe from old local copy @@ -4063,6 +4033,9 @@ class SynchedPropertyTwoWayPU extends ObservedPropertyAbstractPU { // the source_ ObservedProperty will call: this.syncPeerHasChanged(newValue); this.source_.set(newValue); } + else { + stateMgmtConsole.applicationError(`SynchedPropertyTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); + } } /** * Called when sync peer ObservedPropertyObject or SynchedPropertyObjectTwoWay has changed value @@ -4076,19 +4049,6 @@ class SynchedPropertyTwoWayPU extends ObservedPropertyAbstractPU { this.notifyPropertyHasChangedPU(); } } - /** - * called when wrapped ObservedObject has changed poperty - * @param souceObject - * @param changedPropertyName - */ - objectPropertyHasChangedPU(sourceObject, changedPropertyName) { - - this.notifyPropertyHasChangedPU(); - } - objectPropertyHasBeenReadPU(sourceObject, changedPropertyName) { - - this.notifyPropertyHasBeenReadPU(); - } getUnmonitored() { // unmonitored get access , no call to otifyPropertyRead ! @@ -4097,7 +4057,7 @@ class SynchedPropertyTwoWayPU extends ObservedPropertyAbstractPU { // get 'read through` from the ObservedProperty get() { - this.notifyPropertyHasBeenReadPU(); + this.recordDependentUpdate(); return this.getUnmonitored(); } // set 'writes through` to the ObservedProperty @@ -4167,14 +4127,6 @@ class SynchedPropertyNestedObjectPU extends ObservedPropertyAbstractPU { debugInfoDecorator() { return `@ObjectLink (class SynchedPropertyNestedObjectPU)`; } - objectPropertyHasChangedPU(eventSource, changedPropertyName) { - - this.notifyPropertyHasChangedPU(); - } - objectPropertyHasBeenReadPU(sourceObject, changedPropertyName) { - - this.notifyPropertyHasBeenReadPU(); - } getUnmonitored() { // unmonitored get access , no call to notifyPropertyRead ! @@ -4183,7 +4135,7 @@ class SynchedPropertyNestedObjectPU extends ObservedPropertyAbstractPU { // get 'read through` from the ObservedProperty get() { - this.notifyPropertyHasBeenReadPU(); + this.recordDependentUpdate(); return this.obsObject_; } // set 'writes through` to the ObservedProperty @@ -4200,6 +4152,7 @@ class SynchedPropertyNestedObjectPU extends ObservedPropertyAbstractPU { } setValueInternal(newValue) { if (!this.checkIsObject(newValue)) { + stateMgmtConsole.applicationError(`SynchedPropertyNestedObjectPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); return false; } if (this.obsObject_ != undefined) { @@ -4429,7 +4382,7 @@ class ViewPU extends NativeViewPartialUpdate { this.parent_ = undefined; this.childrenWeakrefMap_ = new Map(); // flag for initgial rendering or re-render on-going. - this.isRenderInProgress = false; + this.isRenderInProgress_ = false; // flag if active of inActive // inActive means updates are delayed this.isActive_ = true; @@ -4571,6 +4524,9 @@ class ViewPU extends NativeViewPartialUpdate { this.onInactiveInternal(); } } + isRenderInProgress() { + return this.isRenderInProgress_; + } onActiveInternal() { if (!this.isActive_) { return; @@ -4651,9 +4607,9 @@ class ViewPU extends NativeViewPartialUpdate { stateMgmtConsole.error(`${this.debugInfo()}: updateStateVars unimplemented. Pls upgrade to latest eDSL transpiler version. Application error.`); } initialRenderView() { - this.isRenderInProgress = true; + this.isRenderInProgress_ = true; this.initialRender(); - this.isRenderInProgress = false; + this.isRenderInProgress_ = false; } UpdateElement(elmtId) { if (elmtId == this.id__()) { @@ -4671,13 +4627,13 @@ class ViewPU extends NativeViewPartialUpdate { } else { - this.isRenderInProgress = true; + this.isRenderInProgress_ = true; updateFunc(elmtId, /* isFirstRender */ false); // continue in native JSView // Finish the Update in JSView::JsFinishUpdateFunc // this function appends no longer used elmtIds (as receded by VSP) to the given allRmElmtIds array this.finishUpdateFunc(elmtId); - this.isRenderInProgress = false; + this.isRenderInProgress_ = false; } } @@ -4737,7 +4693,7 @@ class ViewPU extends NativeViewPartialUpdate { // implements IMultiPropertiesChangeSubscriber viewPropertyHasChanged(varName, dependentElmtIds) { stateMgmtTrace.scopedTrace(() => { - if (this.isRenderInProgress) { + if (this.isRenderInProgress_) { stateMgmtConsole.applicationError(`${this.debugInfo()}: State variable '${varName}' has changed during render! It's illegal to change @Component state while build (initial render or re-render) is on-going. Application error!`); } this.syncInstanceId(); diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/observed_object.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/observed_object.ts index 5eb16283725..ce53b0dcee2 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/observed_object.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/observed_object.ts @@ -162,8 +162,8 @@ class SubscribableHandler { var owningProperty: IPropertySubscriber = SubscriberManager.Find(subscribedId) if (owningProperty) { // PU code path - if ('objectPropertyHasBeenReadPU' in owningProperty) { - (owningProperty as unknown as ObservedObjectEventsPUReceiver).objectPropertyHasBeenReadPU(this, propName); + if ('recordDependentUpdate' in owningProperty) { + (owningProperty as unknown as ObservedPropertyAbstractPU).recordDependentUpdate(); } } }); diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property.ts index dd43507ac58..a5a891f6d45 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property.ts @@ -67,13 +67,6 @@ class ObservedPropertyPU extends ObservedPropertyAbstractPU '${changedPropertyName}' has changed.`) this.notifyPropertyHasChangedPU(); } - - public objectPropertyHasBeenReadPU(souceObject: ObservedObject, changedPropertyName : string) { - stateMgmtConsole.debug(`${this.debugInfo()}: objectPropertyHasBeenReadPU: contained ObservedObject property \ - '${changedPropertyName}' has been read.`); - - this.notifyPropertyHasBeenReadPU(); - } private unsubscribeWrappedObject() { if (this.wrappedValue_) { @@ -97,6 +90,7 @@ class ObservedPropertyPU extends ObservedPropertyAbstractPU } if (!this.checkIsSupportedValue(newValue)) { + stateMgmtConsole.applicationError(`ObservedPropertyObjectPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); return false; } @@ -122,7 +116,7 @@ class ObservedPropertyPU extends ObservedPropertyAbstractPU public get(): T { stateMgmtConsole.propertyAccess(`${this.debugInfo()}: get`); - this.notifyPropertyHasBeenReadPU(); + this.recordDependentUpdate(); return this.wrappedValue_; } diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property_abstract.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property_abstract.ts index 6e85ab6f492..ccc66f4b145 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property_abstract.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_observed_property_abstract.ts @@ -195,26 +195,9 @@ implements ISinglePropertyChangeSubscriber, IMultiPropertiesChangeSubscriber, protected notifyPropertyRead() { stateMgmtConsole.error(`${this.debugInfo()}: notifyPropertyRead, DO NOT USE with PU. Use \ - notifyPropertyHasBeenReadPU`); - + recordDependentUpdate`); } - protected notifyPropertyHasBeenReadPU() { - stateMgmtConsole.debug(`${this.debugInfo()}: notifyPropertyHasBeenReadPU.`) - this.subscriberRefs_.forEach((subscriber) => { - if (subscriber) { - // TODO - // propertyHasBeenReadPU is not use in the code - // defined by interface that is not used either: PropertyReadEventListener - // Maybe compiler generated code has it? - if ('propertyHasBeenReadPU' in subscriber) { - (subscriber as unknown as PropertyReadEventListener).propertyHasBeenReadPU(this); - } - } - }); - this.recordDependentUpdate(); - } - protected notifyPropertyHasChangedPU() { stateMgmtConsole.debug(`${this.debugInfo()}: notifyPropertyHasChangedPU.`) if (this.owningView_) { @@ -334,7 +317,10 @@ implements ISinglePropertyChangeSubscriber, IMultiPropertiesChangeSubscriber, * during 'get' access recording take note of the created component and its elmtId * and add this component to the list of components who are dependent on this property */ - protected recordDependentUpdate() { + public recordDependentUpdate() { + if (this.owningView_ && !this.owningView_.isRenderInProgress()) { + return; + } const elmtId = ViewStackProcessor.GetElmtIdToAccountFor(); if (elmtId < 0) { // not access recording @@ -344,6 +330,11 @@ implements ISinglePropertyChangeSubscriber, IMultiPropertiesChangeSubscriber, this.dependentElementIds_.add(elmtId); } + public objectPropertyHasChangedPU(sourceObject: ObservedObject, changedPropertyName : string) { + stateMgmtConsole.debug(`objectPropertyHasChangedPU [${this.id__()}, '${this.info() || "unknown"}']: \ + objectPropertyHasChangedPU: contained ObservedObject property '${changedPropertyName}' has changed.`) + this.notifyPropertyHasChangedPU(); + } public purgeDependencyOnElmtId(rmElmtId: number): void { stateMgmtConsole.debug(`${this.debugInfo()}: purgeDependencyOnElmtId ${rmElmtId}`); diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_nested.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_nested.ts index 9e6f7b81f1b..c7b970509b2 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_nested.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_nested.ts @@ -56,18 +56,6 @@ class SynchedPropertyNestedObjectPU return `@ObjectLink (class SynchedPropertyNestedObjectPU)`; } - public objectPropertyHasChangedPU(eventSource: ObservedObject, changedPropertyName: string) { - stateMgmtConsole.debug(`${this.debugInfo()}: objectPropertyHasChangedPU: property '${changedPropertyName}' \ - of object value has changed.`) - this.notifyPropertyHasChangedPU(); - } - - - public objectPropertyHasBeenReadPU(sourceObject: ObservedObject, changedPropertyName : string) { - stateMgmtConsole.debug(`${this.debugInfo()}: property '${changedPropertyName}' of object value has been read.`); - this.notifyPropertyHasBeenReadPU(); - } - public getUnmonitored(): C { stateMgmtConsole.propertyAccess(`${this.debugInfo()}: getUnmonitored.`); // unmonitored get access , no call to notifyPropertyRead ! @@ -77,7 +65,7 @@ class SynchedPropertyNestedObjectPU // get 'read through` from the ObservedProperty public get(): C { stateMgmtConsole.propertyAccess(`${this.debugInfo()}: get`) - this.notifyPropertyHasBeenReadPU() + this.recordDependentUpdate() return this.obsObject_; } @@ -99,6 +87,7 @@ class SynchedPropertyNestedObjectPU private setValueInternal(newValue: C): boolean { if (!this.checkIsObject(newValue)) { + stateMgmtConsole.applicationError(`SynchedPropertyNestedObjectPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); return false; } diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_one_way.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_one_way.ts index 9bfd6d2640b..339c74d14f6 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_one_way.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_one_way.ts @@ -47,18 +47,11 @@ * rhs can be ObservedObject because of @Observed decoration or now * notifyPropertyHasChangedPU * - * 2- local ObservedObject member property change - * objectPropertyHasChangedPU called, eventSource is the ObservedObject stored in localCopyObservedObject_ - * no need to copy, notifyPropertyHasChangedPU - * - * 3- Rerender of the custom component triggered from the parent + * 2- Rerender of the custom component triggered from the parent * reset() is called (code generated by the transpiler), set the value of source_ , if that causes a change will call syncPeerHasChanged * syncPeerHasChanged need to deep copy the ObservedObject from source to localCopyObservedObject_ * notifyPropertyHasChangedPU * - * 4- source_ ObservedObject member property change - * objectPropertyHasChangedPU called, eventSource is the ObservedObject stored source_.getUnmonitored - * notifyPropertyHasChangedPU */ @@ -99,6 +92,8 @@ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU stateMgmtConsole.debug(`${this.debugInfo()}: constructor: wrapping source in a new ObservedPropertyObjectPU`); this.source_ = new ObservedPropertyObjectPU(sourceValue, this, this.getPropSourceObservedPropertyFakeName()); this.sourceIsOwnObject = true; + } else { + stateMgmtConsole.applicationError(`SynchedPropertyOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); } } @@ -151,21 +146,6 @@ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU } } - /** - * event emited by wrapped ObservedObject, when one of its property values changes - * @param souceObject - * @param changedPropertyName - */ - public objectPropertyHasChangedPU(sourceObject: ObservedObject, changedPropertyName: string) { - stateMgmtConsole.debug(`${this.debugInfo()}: objectPropertyHasChangedPU: property '${changedPropertyName}' of object value has changed.`); - this.notifyPropertyHasChangedPU(); - } - - public objectPropertyHasBeenReadPU(sourceObject: ObservedObject, changedPropertyName : string) { - stateMgmtConsole.debug(`${this.debugInfo()}: objectPropertyHasBeenReadPU: property '${changedPropertyName}' of object value has been read.`); - this.notifyPropertyHasBeenReadPU(); - } - public getUnmonitored(): C { stateMgmtConsole.propertyAccess(`${this.debugInfo()}: getUnmonitored.`); // unmonitored get access , no call to notifyPropertyRead ! @@ -174,7 +154,7 @@ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU public get(): C { stateMgmtConsole.propertyAccess(`${this.debugInfo()}: get.`) - this.notifyPropertyHasBeenReadPU() + this.recordDependentUpdate() return this.localCopyObservedObject_; } @@ -213,6 +193,7 @@ class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU // here because the object might still be the same, but some property of it has changed if(!this.checkIsSupportedValue(newObservedObjectValue)) { + stateMgmtConsole.applicationError(`SynchedPropertyOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); return; } // unsubscribe from old local copy diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_two_way.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_two_way.ts index d884399988b..3fe47e25008 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_two_way.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_two_way.ts @@ -77,8 +77,10 @@ class SynchedPropertyTwoWayPU extends ObservedPropertyAbstractPU stateMgmtConsole.propertyAccess(`${this.debugInfo()}: set: value has changed.`); if (this.checkIsSupportedValue(newValue)) { - // the source_ ObservedProperty will call: this.syncPeerHasChanged(newValue); - this.source_.set(newValue) + // the source_ ObservedProperty will call: this.syncPeerHasChanged(newValue); + this.source_.set(newValue) + } else { + stateMgmtConsole.applicationError(`SynchedPropertyTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: Initial value type unsupported. Application error.`); } } @@ -96,23 +98,6 @@ class SynchedPropertyTwoWayPU extends ObservedPropertyAbstractPU } } - /** - * called when wrapped ObservedObject has changed poperty - * @param souceObject - * @param changedPropertyName - */ - public objectPropertyHasChangedPU(sourceObject: ObservedObject, changedPropertyName : string) { - stateMgmtConsole.debug(`${this.debugInfo()}: objectPropertyHasChangedPU: property '${changedPropertyName}' of \ - object value has changed.`) - - this.notifyPropertyHasChangedPU(); - } - - public objectPropertyHasBeenReadPU(sourceObject: ObservedObject, changedPropertyName : string) { - stateMgmtConsole.debug(`${this.debugInfo()}: objectPropertyHasBeenReadPU: property '${changedPropertyName}' of object value has been read.`); - this.notifyPropertyHasBeenReadPU(); - } - public getUnmonitored(): C { stateMgmtConsole.propertyAccess(`${this.debugInfo()}: getUnmonitored.`); // unmonitored get access , no call to otifyPropertyRead ! @@ -122,7 +107,7 @@ class SynchedPropertyTwoWayPU extends ObservedPropertyAbstractPU // get 'read through` from the ObservedProperty public get(): C { stateMgmtConsole.propertyAccess(`${this.debugInfo()}: get`) - this.notifyPropertyHasBeenReadPU() + this.recordDependentUpdate() return this.getUnmonitored(); } diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_types_events.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_types_events.ts index 399a136a510..1bb6b957f67 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_types_events.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_types_events.ts @@ -49,6 +49,5 @@ interface ObservedObjectEventsPUReceiver { * the propert name is available via ObservedPropertyAbstractPU.Info() */ objectPropertyHasChangedPU(eventSource: ObservedObject, changedPropName: string); - objectPropertyHasBeenReadPU(eventSource: ObservedObject, readPropName: string); } diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_view.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_view.ts index 392383d6ebc..f4c87cb11f7 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_view.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_view.ts @@ -56,7 +56,7 @@ abstract class ViewPU extends NativeViewPartialUpdate private childrenWeakrefMap_ = new Map>(); // flag for initgial rendering or re-render on-going. - private isRenderInProgress: boolean = false; + private isRenderInProgress_: boolean = false; // flag if active of inActive // inActive means updates are delayed @@ -283,6 +283,10 @@ abstract class ViewPU extends NativeViewPartialUpdate } } + public isRenderInProgress() : boolean { + return this.isRenderInProgress_; + } + private onActiveInternal(): void { if (!this.isActive_) { return; @@ -377,9 +381,9 @@ abstract class ViewPU extends NativeViewPartialUpdate } protected initialRenderView(): void { - this.isRenderInProgress = true; + this.isRenderInProgress_ = true; this.initialRender(); - this.isRenderInProgress = false; + this.isRenderInProgress_ = false; } private UpdateElement(elmtId: number): void { @@ -399,13 +403,13 @@ abstract class ViewPU extends NativeViewPartialUpdate stateMgmtConsole.error(`${this.debugInfo()}: update function of elmtId ${elmtId} not found, internal error!`); } else { stateMgmtConsole.debug(`${this.debugInfo()}: updateDirtyElements: re-render of ${componentName} elmtId ${elmtId} start ...`); - this.isRenderInProgress = true; + this.isRenderInProgress_ = true; updateFunc(elmtId, /* isFirstRender */ false); // continue in native JSView // Finish the Update in JSView::JsFinishUpdateFunc // this function appends no longer used elmtIds (as receded by VSP) to the given allRmElmtIds array this.finishUpdateFunc(elmtId); - this.isRenderInProgress = false; + this.isRenderInProgress_ = false; stateMgmtConsole.debug(`${this.debugInfo()}: updateDirtyElements: re-render of ${componentName} elmtId ${elmtId} - DONE`); } } @@ -474,7 +478,7 @@ abstract class ViewPU extends NativeViewPartialUpdate // implements IMultiPropertiesChangeSubscriber viewPropertyHasChanged(varName: PropertyInfo, dependentElmtIds: Set): void { stateMgmtTrace.scopedTrace(() => { - if (this.isRenderInProgress) { + if (this.isRenderInProgress_) { stateMgmtConsole.applicationError(`${this.debugInfo()}: State variable '${varName}' has changed during render! It's illegal to change @Component state while build (initial render or re-render) is on-going. Application error!`); } -- Gitee