type ObservableOptions = { onRead?: (key: string[], value: any) => any; onWrite?: (key: string[], newValue: any) => any; onDelete?: (key: string[]) => any; trigger?: 'default' | 'full'; }; /** * * 创建对象的可观察代理 * * 如 * obj = observable({a:1,b:2,C:{c1:1,c2:2},d:[1,2,3]},{ * onRead:(key)=>{console.log('read',key)}, * onWrite:(key,value)=>{ * }) * * 当读取obj.a时,会触发onRead(['a']) * 当读取obj.C.c1时,会触发onRead(['C','c1']) * 当写入obj.a时,会触发onWrite(['a'],value) * 当写入obj.C.c1时,会触发onWrite(['C','c1'],value) * * onRead和onWrite的返回值会作为读取或写入的结果 * 支持嵌套对象和数组 * * * @param target * @param options */ declare function observable(target: T, options?: ObservableOptions): T; export { type ObservableOptions, observable };