import { Target } from '../shared/svu' ; import { hasChanged , isObject } from '../shared' ; import { track , trigger } from './effect' ; import { reactive } from './reactive' ; function createGetter ( ) { return ( target , key , receiver ) => { let res = Reflect . get ( target , key , receiver ) ; track ( target , key ) ; if ( isObject ( res ) ) { return reactive ( res ) ; } return res ; } ; } function createSetter ( ) { return ( target , key , value , receiver ) : boolean => { const oldValue = ( target as any ) [ key ] ; const result = Reflect . set ( target , key , value , receiver ) ; if ( hasChanged ( value , oldValue ) ) { trigger ( target , key , value ) ; } return result ; } ; } const get = createGetter ( ) ; const set = createSetter ( ) ; export const mutableHandlers = { get , set , } ;