import { Dep } from './Dep' ; export function Observe ( obj , vm ) { Object . keys ( obj ) . forEach ( function ( key ) { defineReactive ( vm , key , obj [ key ] ) ; } ) ; } function defineReactive ( obj , key , val ) { let dep = new Dep ( ) ; Object . defineProperty ( obj , key , { get : function ( ) { if ( Dep . target ) { dep . addDep ( Dep . target ) ; } return val ; } , set : function ( newVal ) { if ( newVal === val ) return ; val = newVal ; dep . notify ( ) ; } } ) ; }