I was trying js-data 3.0.0-rc.9. I have few doubts regarding event listeners for data changes and how to use it.
Users JSON:
{
id: '',
nested : { attr: '', attr2: ""},
arr : [{},{} ..],
username : ""
}
store.find('user',1).then(function(data){
//data - object(record)
data.on('change',function(data,changes){
//Object changes
});
});
store.findAll('user').then(function(data){
//data - array of objects(records)
//How to observe any addition/removal in array
});
I was able to
1) Listen to the data change done in a object using .on('change') listener.
store.get('user',1).username = "Changed name" //It works :D
I was not able to
1) Listen to nested data change in a object.
store.get('user',1).nested.attr = "something" //It doesn't work. :(
store.get('user',1).set('nested',{}) //It works
2) Listen to array data changes (adding, removing)
//How to do. ?
Correct me if i am doing anything wrong.
It would be so much helpful if there is a complete example regarding the event listeners for those changes.
Thanks in advance.