-
Notifications
You must be signed in to change notification settings - Fork 23
Description
I think freactive has pretty well removed the insanity inherent to the task of providing coherent, coordinated views on ever-changing data, thanks to your work. Now, though, instead of using a simple hash-map wrapped in a reactive atom as my datasource, I want to use Datomic or possibly Datascript (an in-browser ClojureScript database which seeks to model/reproduce Datomic). Being nowhere near as intimately familiar with the internals of freactive as you, of course, I was wondering: what, in your opinion, would be the best way to go about using freactive with these kinds of more complex datasources?
I came across this gist (specifically lines 136-200) which uses a cursor over a reactive atom wrapped around a Datascript database, which is a hash-map anyway. The difference is that instead of using keywords or the like as cursor-fns, it uses a query function. How would freactive listen to the changes in the database which the query fn would intend to "subscribe" to?
Even so, the question of Datascript seems a relatively easy one compared to that of Datomic. After all, a Datascript database is really just a hash-map with schemas and Datalog-like queriablity (is that a word?) built in (and other things, but we'll ignore that). The entire Datascript database is in-memory and seems conceptually quite similar to the use cases in which I've used freactive (i.e., using a ClojureScript hash-map as the global application state). However, Datomic is an abstraction over an actual database, in this case remote with respect to the client, with latency and the potential for connection-interruptions, for which reactive watch notifications ("subscriptions") seem to be more conceptually difficult to implement. (However, not being entirely familiar with the internals of freactive, I can't with total certainty assert that this is the case.) Is the solution to instead cache the relevant parts of the database in a global-application-state hash-map on the client and have an push-queue with updates from the client to the database and a pull-queue with updates from the database to the client?
Bear with me, as many of these concepts are fairly new to me and I may not be expressing them very well.
I appreciate your time. Thanks!