@@ -3,9 +3,11 @@ import { QError, qError } from '../error/error';
33import  {  isQrl  }  from  '../import/qrl-class' ; 
44import  {  notifyRender  }  from  '../render/notify-render' ; 
55import  {  tryGetInvokeContext  }  from  '../use/use-core' ; 
6+ import  {  isElement  }  from  '../util/element' ; 
67import  {  logWarn  }  from  '../util/log' ; 
78import  {  qDev ,  qTest  }  from  '../util/qdev' ; 
89import  {  debugStringify  }  from  '../util/stringify' ; 
10+ import  {  runWatch ,  WatchDescriptor  }  from  '../watch/watch.public' ; 
911
1012export  type  ObjToProxyMap  =  WeakMap < any ,  any > ; 
1113export  type  QObject < T  extends  { } >  =  T  &  {  __brand__ : 'QObject'  } ; 
@@ -94,7 +96,10 @@ type TargetType = Record<string | symbol, any>;
9496
9597class  ReadWriteProxyHandler  implements  ProxyHandler < TargetType >  { 
9698  private  subscriber ?: Element ; 
97-   constructor ( private  proxyMap : ObjToProxyMap ,  private  subs  =  new  Map < Element ,  Set < string > > ( ) )  { } 
99+   constructor ( 
100+     private  proxyMap : ObjToProxyMap , 
101+     private  subs  =  new  Map < Element  |  WatchDescriptor ,  Set < string > > ( ) 
102+   )  { } 
98103
99104  getSub ( el : Element )  { 
100105    let  sub  =  this . subs . get ( el ) ; 
@@ -147,15 +152,15 @@ class ReadWriteProxyHandler implements ProxyHandler<TargetType> {
147152    const  isArray  =  Array . isArray ( target ) ; 
148153    if  ( isArray )  { 
149154      target [ prop  as  any ]  =  unwrappedNewValue ; 
150-       this . subs . forEach ( ( _ ,  el )  =>  notifyRender ( el ) ) ; 
155+       this . subs . forEach ( ( _ ,  sub )  =>  notifyChange ( sub ) ) ; 
151156      return  true ; 
152157    } 
153158    const  oldValue  =  target [ prop ] ; 
154159    if  ( oldValue  !==  unwrappedNewValue )  { 
155160      target [ prop ]  =  unwrappedNewValue ; 
156-       this . subs . forEach ( ( propSets ,  el )  =>  { 
161+       this . subs . forEach ( ( propSets ,  sub )  =>  { 
157162        if  ( propSets . has ( prop ) )  { 
158-           notifyRender ( el ) ; 
163+           notifyChange ( sub ) ; 
159164        } 
160165      } ) ; 
161166    } 
@@ -174,6 +179,14 @@ class ReadWriteProxyHandler implements ProxyHandler<TargetType> {
174179  } 
175180} 
176181
182+ export  function  notifyChange ( subscriber : Element  |  WatchDescriptor )  { 
183+   if  ( isElement ( subscriber ) )  { 
184+     notifyRender ( subscriber ) ; 
185+   }  else  { 
186+     runWatch ( subscriber  as  WatchDescriptor ) ; 
187+   } 
188+ } 
189+ 
177190function  verifySerializable < T > ( value : T )  { 
178191  if  ( shouldSerialize ( value )  &&  typeof  value  ==  'object'  &&  value  !==  null )  { 
179192    if  ( Array . isArray ( value ) )  return ; 
0 commit comments