"Recollect" is a small library I created to sync data from server to clients. The idea behind Recollect is React's DOM diff/patching.
To sync states across all clients in realtime, we are facing a similar problem: clients data are created based the same database, when database is updated, all clients need to update their copies of data in their browsers. Mean networks is slow, we should only send the changed parts over the network. And, this is almost what we have done with React.
Recollect is implemented in ClojureScript since we rely persistent data structure heavily. And many tricks are required to make it performant because we all know diffing can be slow, no mention doing it on server side.
Currently there are several updating operations in Recollect:
[:m/! coord x] ; reset data
[:m/- coord k] ; remove key from map
[:v/+! coord xs] ; append to vector
[:v/-! coord k] ; remove after index k
[:st/++ coord xs] ; add to set
[:st/-- coord xs] ; remove from set
[:sq/-+ coord [k xs]] ; drop k items and add sequence
For Vectors and Sequences, since they are operated from head/tail, it's slow to update in the middle.
It's fine in current stage of experimenting. I'm wondering if we can achieve better performance and reliability with better algorithms, any ideas?
updates: I got some examples: