1.3.4 • Published 1 year ago

lazy-watch v1.3.4

Weekly downloads
2
License
ISC
Repository
github
Last release
1 year ago

LazyWatch

Deep watch objects (using Proxy) and emit diff asynchronously.

Install:

npm i lazy-watch

Simple Usage:

const UI = new LazyWatch({})
LazyWatch.on(UI, diff => console.log({ diff }))
UI.hello = 'world'

Example:

const initialData = () => {
  return { pretty: false, list: [{ nice: false  }], right: true, junk: 123 }
}
const UI = new LazyWatch(initialData())
const mirror = new LazyWatch(initialData())
const changeListener = diff => {
  console.log({ diff })
  // the diff could be sent via websocket to another browser or something
  LazyWatch.patch(mirror, diff)
}
LazyWatch.on(UI, changeListener)

UI.pretty = true;
UI.list[0].forEach(item => {
  item.nice = true
})
delete UI.junk
// this will result in changeListener getting called once with all changes
1.2.0

1 year ago

1.1.8

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.4

2 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago