borg-collective
v1.2.95
Published
Document level hive mind interface for Attila - Resistance is futile.
Downloads
116
Keywords
Readme
Resistance is futile
Specifying listeners
Listeners can be added by calling "onChange" on the instantiated collective with a listener config object. The object should have a property "path" which is a string or array of string paths which point to the path in the document you wish to listen to. the second argument should be the change handler.
const myChangeHandler = function( stateByPath, change )
{
console.log( Object.keys( stateByPath ) )
// prints [ "user.name", "user.age" ]
console.log( change.path, change.value)
// prints "user.name henk"
}
collective.onChange({
path: [ 'user.name', 'user.age' ],
handler: myChangeHandler
})