mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
!48419 unregister computedid from viewv2
Merge pull request !48419 from LiWenzhen/unregisterComputedId
This commit is contained in:
commit
85980489a6
@ -6511,8 +6511,6 @@ class ViewPU extends PUV2ViewBase {
|
||||
|
||||
// in case this ViewPU is currently frozen
|
||||
PUV2ViewBase.inactiveComponents_.delete(`${this.constructor.name}[${this.id__()}]`);
|
||||
// FIXME needed ?
|
||||
MonitorV2.clearWatchesFromTarget(this);
|
||||
this.updateFuncByElmtId.clear();
|
||||
this.watchedProps.clear();
|
||||
this.providedVars_.clear();
|
||||
@ -7452,6 +7450,8 @@ class ObjectProxyHandler {
|
||||
const conditionalTarget = this.getTarget(target);
|
||||
// makeObserved logic adds wrapper proxy later
|
||||
let ret = this.isMakeObserved_ ? target[key] : ObserveV2.autoProxyObject(target, key);
|
||||
// do not addref for function type, it will make such huge unnecessary dependency collection
|
||||
// for some common function attributes, e.g. toString etc.
|
||||
if (typeof (ret) !== 'function') {
|
||||
ObserveV2.getObserve().addRef(conditionalTarget, key);
|
||||
return (typeof (ret) === 'object' && this.isMakeObserved_) ? RefInfo.get(ret).proxy : ret;
|
||||
@ -9102,6 +9102,16 @@ class ComputedV2 {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static clearComputedFromTarget(target) {
|
||||
var _a;
|
||||
let meta;
|
||||
if (!target || typeof target !== 'object' ||
|
||||
!(meta = target[ObserveV2.COMPUTED_REFS]) || typeof meta !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
Array.from(Object.values(meta)).forEach((computed) => ObserveV2.getObserve().clearWatch(computed.computedId_));
|
||||
}
|
||||
}
|
||||
// start with high number to avoid same id as elmtId for components.
|
||||
ComputedV2.MIN_COMPUTED_ID = 0x1000000000;
|
||||
@ -9274,6 +9284,7 @@ class ViewV2 extends PUV2ViewBase {
|
||||
|
||||
PUV2ViewBase.inactiveComponents_.delete(`${this.constructor.name}[${this.id__()}]`);
|
||||
MonitorV2.clearWatchesFromTarget(this);
|
||||
ComputedV2.clearComputedFromTarget(this);
|
||||
this.updateFuncByElmtId.clear();
|
||||
if (this.parent_) {
|
||||
this.parent_.removeChild(this);
|
||||
|
@ -232,9 +232,6 @@ abstract class ViewPU extends PUV2ViewBase
|
||||
// in case this ViewPU is currently frozen
|
||||
PUV2ViewBase.inactiveComponents_.delete(`${this.constructor.name}[${this.id__()}]`);
|
||||
|
||||
// FIXME needed ?
|
||||
MonitorV2.clearWatchesFromTarget(this);
|
||||
|
||||
this.updateFuncByElmtId.clear();
|
||||
this.watchedProps.clear();
|
||||
this.providedVars_.clear();
|
||||
|
@ -108,6 +108,17 @@ class ComputedV2 {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static clearComputedFromTarget(target: Object): void {
|
||||
let meta: Object;
|
||||
if (!target || typeof target !== 'object' ||
|
||||
!(meta = target[ObserveV2.COMPUTED_REFS]) || typeof meta !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
stateMgmtConsole.debug(`ComputedV2: clearComputedFromTarget: from target ${target.constructor?.name} computedIds to clear ${JSON.stringify(Array.from(Object.values(meta)))}`);
|
||||
Array.from(Object.values(meta)).forEach((computed: ComputedV2) => ObserveV2.getObserve().clearWatch(computed.computedId_));
|
||||
}
|
||||
}
|
||||
|
||||
interface AsyncAddComputedJobEntryV2 {
|
||||
|
@ -61,6 +61,8 @@ class ObjectProxyHandler {
|
||||
|
||||
// makeObserved logic adds wrapper proxy later
|
||||
let ret = this.isMakeObserved_ ? target[key] : ObserveV2.autoProxyObject(target, key);
|
||||
// do not addref for function type, it will make such huge unnecessary dependency collection
|
||||
// for some common function attributes, e.g. toString etc.
|
||||
if (typeof (ret) !== 'function') {
|
||||
ObserveV2.getObserve().addRef(conditionalTarget, key);
|
||||
return (typeof (ret) === 'object' && this.isMakeObserved_) ? RefInfo.get(ret).proxy : ret;
|
||||
|
@ -152,6 +152,7 @@ abstract class ViewV2 extends PUV2ViewBase implements IView {
|
||||
PUV2ViewBase.inactiveComponents_.delete(`${this.constructor.name}[${this.id__()}]`);
|
||||
|
||||
MonitorV2.clearWatchesFromTarget(this);
|
||||
ComputedV2.clearComputedFromTarget(this);
|
||||
|
||||
this.updateFuncByElmtId.clear();
|
||||
if (this.parent_) {
|
||||
|
Loading…
Reference in New Issue
Block a user