0.7.3 • Published 4 months ago
james-bond v0.7.3
James Bond
Hire James Bond to observe your (object) targets.
Summary
Use james-bond
to observe changes to properties in objects.
Usage
observe(obj)
/unobserve(obj)
Observe particular properties of an object (non-deeply).
import * as bond from 'james-bond'
const janus = {
name: 'Alec Trevelyan',
stats: {
kills: 8,
},
kill(someone) {
console.log('killed ' + someone)
this.stats.kills++
},
}
const callback = (key, value) => {
console.log(key, value)
}
bond.observe(janus, ['name'], callback)
bond.observe(janus.stats, ['kills'], callback)
setTimeout(() => {
janus.name = 'Janus' // logs "name Janus"
janus.kill('someone') // logs "kills 9"
}, 1000)
Later, unobserve when done:
// Unobserve all props for the given callback (in this case, just "kills")
bond.unobserve(janus.stats, callback)
// Alternatively, unobserve specific props for the given callback.
bond.unobserve(janus, ['name'], callback)
Roadmap
- Add deferral options, f.e. to have updates batched into a microtask or animation frame.
0.7.3
4 months ago
0.7.2
5 months ago
0.7.1
6 months ago
0.7.0
6 months ago
0.6.0
7 months ago
0.5.1
7 months ago
0.5.0
2 years ago
0.4.5
3 years ago
0.4.4
4 years ago
0.4.3
4 years ago
0.4.2
6 years ago
0.4.1
6 years ago
0.4.0
6 years ago
0.3.0
6 years ago
0.2.1
6 years ago
0.2.0
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago
0.0.0
10 years ago