@@ -6,10 +6,14 @@ import type { IRelatedPathValue } from './data-tracer'
66
77const deepClone = rfdc ( { proto : true } )
88
9+ interface BehaviorData {
10+ '_computedWatchInit' : ComputedWatchInitStatus ;
11+ [ k : string ] : any ;
12+ }
913
1014interface BehaviorExtend {
1115 // original
12- data : Record < string , any > ;
16+ data : BehaviorData ;
1317 setData ( d : Record < string , any > ) : void ;
1418 _computedWatchInfo : Record < string , ComputedWatchInfo > ;
1519}
@@ -26,18 +30,23 @@ interface ComputedWatchInfo {
2630 _triggerFromComputedAttached : Record < string , boolean > ;
2731}
2832
33+ enum ComputedWatchInitStatus {
34+ CREATED ,
35+ ATTACHED
36+ }
37+
2938let computedWatchDefIdInc = 0
3039
3140export const behavior = Behavior ( {
3241 lifetimes : {
3342 attached ( this : BehaviorExtend ) {
3443 this . setData ( {
35- _computedWatchInit : 'attached' ,
44+ _computedWatchInit : ComputedWatchInitStatus . ATTACHED ,
3645 } )
3746 } ,
3847 created ( this : BehaviorExtend ) {
3948 this . setData ( {
40- _computedWatchInit : 'created' ,
49+ _computedWatchInit : ComputedWatchInitStatus . CREATED ,
4150 } )
4251 } ,
4352 } ,
@@ -51,7 +60,7 @@ export const behavior = Behavior({
5160 fields : '_computedWatchInit' ,
5261 observer ( this : BehaviorExtend ) {
5362 const status = this . data . _computedWatchInit
54- if ( status === 'created' ) {
63+ if ( status === ComputedWatchInitStatus . CREATED ) {
5564 // init data fields
5665 const computedWatchInfo = {
5766 computedUpdaters : [ ] ,
@@ -74,7 +83,7 @@ export const behavior = Behavior({
7483 computedWatchInfo . watchCurVal [ watchPath ] = curVal
7584 } )
7685 }
77- } else if ( status === 'attached' ) {
86+ } else if ( status === ComputedWatchInitStatus . ATTACHED ) {
7887 // handling computed
7988 // 1. push to initFuncs
8089 // 2. push to computedUpdaters
0 commit comments