Opened 9 years ago

Closed 7 years ago

#16865 closed defect (worksforme)

dojo/store/Observable does not notify for changed entries

Reported by: Alexander Kläser Owned by: Kris Zyp
Priority: undecided Milestone: 1.11
Component: Data Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:


We are using Dojo 1.8.3 and experience problems with the notification mechanism on the Memory store. It seems that notifications on object changes themselves are not registered correctly:

m = new require('dojo/store/Observable')(require('dojo/store/Memory')({}));
m.put({id:1, label:'first element'});
m.put({id:2, label:'second element'});
res = m.query();
// normal observe
res.observe(function() { console.log('observe1:', arguments)});
// observe with includeObjectUpdates==true
res.observe(function() { console.log('observe2:', arguments)}, true);
m.put({id:3, label:'third element'});
// → "observe1: [Object, -1, 2]"
// → "observe2: [Object, -1, 2]"
m.put({id:2, label:'the second element'});
// → nothing happens
// → "[Object, Object, Object, total: 2, observe: function]"
// → "3"

Is it correct the res contains automatically 3 objects, yet says total==2 ?

Change History (3)

comment:1 Changed 9 years ago by Alexander Kläser

A different question, how is Memory supposed to behave if I query an element, edit it directly, and put it back, i.e.:

i = m.query()[0];
i.label = 'first element - changed label';

Would a listener be notified? The piece of code is directly changing the referenced object in the Memory store, such that Observable.observe() would not be able to identify the change.

Last edited 9 years ago by Alexander Kläser (previous) (diff)

comment:2 Changed 9 years ago by Alexander Kläser

Hm, it seems, if the first call to 'res.observe()' sets includeObjectUpdates==true, it works.

comment:3 Changed 7 years ago by dylan

Milestone: tbd1.11
Resolution: worksforme
Status: newclosed

It looks like you answered your own question, so closing this. Please reopen if still an issue.

Note: See TracTickets for help on using tickets.