Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 444 Bytes

README.md

File metadata and controls

18 lines (17 loc) · 444 Bytes

obj-observer

js/ts 对象监听

  1. 安装依赖
npm install obj-observer
# 或 npm i
  1. 在需要的地方引入watch方法,监听对象或数组的变化
import {ref,watch} from 'obj-observer'
const obj=ref({test:123})
const dispose=watch(obj,
    (value,oldValue)=>{
        console.log('trigger change',value,oldValue)
    })
obj.test='hi world' //'trigger change' {test:'hello world'} {test:'hi world'}