Skip to content

Releases: jsutilslib/activeobject

activeobject as part of jsutilslib 1.0.0-beta

03 Dec 09:28

Choose a tag to compare

ActiveObject is a library that converts an object into an active object that can emit events when one of its properties changes its value.

It enables creating objects and subscribing to modifications of them. So having

let people = [ { name: "Alice" }, { name: "Bob" } ]
let a_people = ActiveObject(people)
a_people.watch('*.name', function (e) {
    console.log('the list of people has changed', e)
})

if we make a change like a_people[1].name = 'John', the function in the watch will be triggered.

ActiveObject is part of jsutilslib, so please consider using the whole library.