Thank you for the response. I'll reply to you inline:
On Sat, Nov 14, 2009 at 7:38 PM, Kris Zyp <kri...@gmail.com> wrote:
>
> Are both onSet events providing different new values (is the old value
> always different than the new)?
The old value is always different than the new value. onSet is never
called with arguments set such that oldValue == newValue. However,
onSet is consistently called with all arguments equal to the arguments
that had been set when onSet had been called a previous time. Ordering
also appears to be respected.
I think the original trace I included is fairly representative:
set item received
transform
matrix(1,0,0,1,256,324)
matrix(1,0,0,1,257,325)
PUT http://localhost:8080/Graphics/2
200 OK
189ms bootstrap.js (line 1115)
set item received
transform
matrix(1,0,0,1,257,325)
matrix(1,0,0,1,258,326)
PUT http://localhost:8080/Graphics/2
200 OK
90ms bootstrap.js (line 1115)
set item received
transform
matrix(1,0,0,1,258,326)
matrix(1,0,0,1,259,327)
PUT http://localhost:8080/Graphics/2
200 OK
50ms bootstrap.js (line 1115)
set item received
transform
matrix(1,0,0,1,259,327)
matrix(1,0,0,1,257,325)
set item received
transform
matrix(1,0,0,1,257,325)
matrix(1,0,0,1,258,326)
set item received
transform
matrix(1,0,0,1,258,326)
matrix(1,0,0,1,259,327)
Here, onSet is called six times in total. The first three times were
triggered by calls to setValue. Each one creates a new XHR to PUT and
update a resource on the server. These occur inside of a tight loop.
The last three times onSet is called, it is triggered by
_watchInFlight in xhr.js, which is connected to
dojox.rpc.Rest._index.onUpdate. You can see that the arguments are the
same as in the first three events, and ordering is also preserved. The
problem is that these events have already been handled by onSet.
> Is the client changing the value of the
> property and then the server changing it to something else, or is the
> second event being triggered even the value isn't changed?
No, the issue is not consistency in the data between the client and
the server, but is simply in the number of times onSet gets called for
each call to setValue.
I want to be a little bit formal in how I answer this, just so that
there's no confusion.
The server has a resource R. The client has a local store S which
contains a resource R'. The resource R and R' have properties p. R'.p
and R.p initially have values of x0. The client will update R'.p to a
value x1 via S.setValue, onSet will be called with arguments (R', p,
x0, x1). The client will then call S.save(), and an XHR PUT xhr1 will
be created to asynchronously update R.p to x1.
Before xhr1 completes, the client will update R'.p to a new value x2.
onSet will again be called from the setValue method, this time with
args (R', p, x1, x2). The client will then call S.save(), and an XHR
PUT xhr2 will be created to asynchronously update R.p to x2.
When xhr1 completes, the value of R.p will be x1, and onSet will be
called When xhr2 completes, the value of R.p will be x2. So, the
value of the data resources is completely consistent between client
and server.
The problem is that when xhr1 completes, _watchInFlight will be
called which triggers dojox.rpc.Rest._index.onUpdate, which calls
onSet(R',p,x0,x1). Likewise, when xhr2 completes, onSet will be called
with (R',p,x1,x2).
The problem is, onSet has already been called with these values once
before. This behaviour does not seem to me to be consistent.
Please let me know if you have any more questions. I'll put a sample
online soon so that, if it is still unclear, you will be able to trace
this behaviour yourself.
Thanks for looking into this,
Jake
http://echo-flow.com:8080/graphics/graphics.xhtml
You can trace it yourself with firebug. Pressing any key will trigger
the behaviour in question.
Please let me know what you think. Thanks,
Jake