PDA

View Full Version : Defer JsonWriter's automatic save calls?



mw-flow
29 May 2009, 7:11 AM
Hi all,

i use a JsonStore that has a JsonWriter configured in order to write changes to the store back to the server. The remove and the insert method of the store fire the corresponding remove and insert event immediatly. Everytime they do this, however, the store's save method seems to be called, resulting in an immediate POST request to the server. In my case, I always need to save all of the store's records back to the server. So to decrease the number of POST requests to avoid network latency time, I'd like to defer the save calls for say 500ms after the last remove/insert event. How can I do this?

Thanks a lot :-)

mw-flow

jay@moduscreate.com
1 Jun 2009, 5:40 AM
From my experience, writer won't dump all of teh store's records. your case is pretty unique. Most people CRUD on records, not on a store.

mw-flow
2 Jun 2009, 12:16 AM
Hi Jay,

thanks for your reply. And you're right, of course, my case is pretty unique. Do you think it's sensible in my case to just subclass the JsonStore, write the insert and remove method in a way that they don't fire the insert/remove event and call store.save() manually after the calls to insert/remove?

<edit>Hmmm... I just noticed that Record's endEdit method again triggers the store to call its save method. So I would have to use a different Record class all over the place and, thus, I would probably have to use a different Store class that would be using that new Record class all over... right?</edit>

<edit2>Hmmmmmm... why does my store's save method get called anyway? The 3.0 RC-1.1 documentation says for the batchSave config option "Defaults to false, which requires manually calling save to send all modifiedRecords to the server. Specify true for the store to automatically save records to the server when a record changes." I haven't set batchSave to anything, so save should not be called anyway after each insert/remove or call to endEdit of a record, right?</edit2>

Best regards
mw-flow

mw-flow
5 Jun 2009, 12:20 AM
Bump - Thanks for having a look.

mw-flow
15 Jun 2009, 1:01 AM
The batchSave issue still bugs me. The Documentation says for batchSave: "Defaults to false, which requires manually calling save to send all modifiedRecords to the server. Specify true for the store to automatically save records to the server when a record changes."

However, my Store get saved after each change despite me not having set batchSave to true...

mw-flow
23 Jun 2009, 4:36 AM
The batchSave issue still bugs me. The Documentation says for batchSave: "Defaults to false, which requires manually calling save to send all modifiedRecords to the server. Specify true for the store to automatically save records to the server when a record changes."

However, my Store get saved after each change despite me not having set batchSave to true...


No reply for 8 days now despite 164 thread views. Hmmm... to make answering easier:

[ ] no-one needs batchSave = false
[ ] the documentation is wrong
[ ] it is a bug in 3.0 RC-1.1 beta
[ ] my question was just plain silly and i should stick my head in the sand

Check all that apply.

chesstrix
3 Aug 2009, 9:27 PM
I have the same need to dump all of the changed records in a store at one point. So your issue is certainly not unique.

I read the docs as batch (not batchSave) true to send all recs as one transaction but only id autoSave is also set to false.

I have only just begun to implement this but instantly found that if I modify one record and then force a store.save() that two identical transactions are fired off. It's as if the autoSave: false is doing nothing?

Still investigating...

Oops, my bad. It helps if you put the autoSave on the Store NOT the JsonWriter