matterandvoid-space / subscriptions

A subscriptions library over a source of data (forked + extracted from re-frame)
Other
50 stars 1 forks source link

Idea: implement clojure reactive support using missionary #1

Open dvingo opened 2 years ago

dvingo commented 2 years ago

The code works in clojure without the reactive part. It would be interesting to also have subscriptions work in clojure.

example use-case: listening to a transaction log for a db -> run through subscription chain on the server -> websocket -> subscription chain on the client.

For implementation, I think https://github.com/leonoel/missionary could work. The idea is to make https://github.com/matterandvoid-space/subscriptions/blob/94f8b663d70f1fb0d860634c619cc614bb1f0d2e/src/main/space/matterandvoid/subscriptions/impl/reagent_ratom.clj#L38 run-in-reaction and make-reaction work on clojure.

I suppose you could also just try a faithful port of the reagent.ratom namespace (and support namespaces) into clojure but figured missionary would be the simpler route of those options.

Another interesting/crazy idea is to use missionary on the client as well instead of reagent but maintain the use-sub user-level API - just swapping implementations.

dvingo commented 2 years ago

looks like this was already done here! https://github.com/jpmonettas/posh/blob/master/src/posh/lib/ratom.cljc

dvingo commented 2 years ago

also see praxis https://github.com/ribelo/praxis/tree/master/examples/todomvc/src/todomvc