Hi Anton, Yes, the change is sent to the server as soon as the change occurs. They could also be bunched up and sent when there are say 20k bytes of changes to be sent, but I haven't found any performance problems yet, so I haven't had to do that yet, but in the future this is very likely how it will work.
To restore the state I just set up the initial state in the browser, an empty map, and then read the changes sequentially from the server, which I then assoc into the client state. The changes are all handled by atoms in Clojurescript, so not much that I have to do except read the changes in the cirrect order and apply them. I do however store a timestamp with each change so that it can replay the change at exactly the same time as it orginally happened. Try it, try moving your mouse in the browser at different speeds and it should play back the same. The playback happens here (note that everything stored in Neo4j on the server). The server part to add history: https://github.com/zubairq/coils/search?q=%28defn+%21add-history&ref=cmdform :and replaying the session on the client is here: https://github.com/zubairq/coils/search?q=%28defn+playback-session+%5B%26+%7B%3Akeys&ref=cmdform Let me know if it helps or if you need more explanation. Zubair On Thursday, July 24, 2014 8:17:39 PM UTC+2, Anton Astashov wrote: > Hi! > > Thanks for answers! :) > > So, Zubair, you send only the change immediately after its occur in the > global state to the server. That makes sense, but makes things a bit more > difficult. What about restoring the state from the server? How do you build > that structure with shared substructures in browser's memory? It basically > should be something like creating shared substructures first, and then > assigning them here and there in a big global one. Do you do something like > that in your framework? If yes, where should I look at? > > Thanks! > > On Wednesday, July 23, 2014 9:28:44 PM UTC-7, Zubair Quraishi wrote: > > Hi Anton, > > > > In the Coils framework it does actually share structures (atoms) from the > > client to the server, which can then be replayed back to the client again. > > An example is at: > > > > http://connecttous.co/ > > > > :where you can play around with the sample application, and then you can go > > to: > > > > http://connecttous.co/connecttous/connecttous.html?playback=true > > > > : to play back the sessions. The way this is done is by just sending the > > updates of the Om Application State to the server (assuming you are using > > David Nolen's Om for the client side) using Om's tx-listen. Here is where > > the code is: > > > > https://github.com/zubairq/coils/search?q=tx-listen&ref=cmdform > > > > : tx-listen takes two arguments, the first of which contains the changes: > > > > (fn [tx-data root-cursor] > > > > : so you can do (:path tx-data) to get just the changes to the GUI, which > > is what Coils does, and then it sends those changes to the server. To see > > the changes being sent live to the server, if you go to connecttous.co and > > do stuff in the GUI, then open the network console, you can see calls to > > the server which send the GUI state from client to server, by looking out > > for the calls which are something like this: > > > > http://connecttous.co/connecttous/action?systemaction=!add-history¶ms=.... > > > > :This sends the GUI changes back to the server, which then get stored in > > the backend. > > > > > > Regarding Andrew Chamber's point about tree diff, Andrew is spot on! In > > fact when you do local debugging in Coils: > > > > http://connecttous.co/connecttous/connecttous.html?livedebug=true > > > > : on the right you can see changes to two trees that Coils uses, called UI > > and DATA. To show these changes it uses the Clojure diff call: > > > > https://github.com/zubairq/coils/search?q=deleted+++++%28first+&type=Code > > > > :which shows added and deleted entries from the trees. I hope this helps > > and that you can apply something similar to your own project. > > > > Thanks > > Zubair -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
