huntress
A mad method of observing deep object properties and getting callbacks for when they change. Awesome for simple state management.
// start tracking changes to a user's usernameStateStateuser = name: 'Joe Bloggs'Stateuserusername = 'joe'// LOG -- Username is: joeStateuser = name: 'David' username: 'daveyjones'// LOG -- Username is: daveyjones// -----// even works with arraysStateStateuserkeys = name: 'foo'Stateuserkeys// LOG -- Second key name is: barStateuserkeysStateuserkeys = name: 'wham' name: 'bam'// LOG -- Second key name is: bamStateuserkeys =// LOG -- Second key name is: undefined
Todo
- Throw callbacks on
delete
calls - Parse strings like
'user.keys[0].name'
instead of requiring an array of arguments 🤮 - Be able to throw initial callbacks to get listeners up to speed
- Document
- Tests