obj-observer
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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'} 

Readme

Keywords

Package Sidebar

Install

npm i obj-observer

Weekly Downloads

3

Version

1.0.4

License

MIT

Unpacked Size

14.2 kB

Total Files

9

Last publish

Collaborators

  • lc_cn