This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-09
Channels
- # announcements (23)
- # asami (25)
- # babashka (38)
- # beginners (53)
- # calva (17)
- # clara (5)
- # clj-commons (1)
- # clj-kondo (18)
- # clojure (11)
- # clojure-europe (17)
- # clojure-france (1)
- # clojure-germany (5)
- # clojure-nl (2)
- # clojure-sg (4)
- # conjure (3)
- # deps-new (6)
- # fulcro (16)
- # off-topic (46)
- # pedestal (11)
- # react (2)
- # reagent (5)
- # reclojure (7)
- # rewrite-clj (1)
- # sci (18)
- # shadow-cljs (75)
- # sql (3)
- # xtdb (12)
@quoll I'd like an opinion; I have an in-memory db with asami
, and from some of the query in that database I'd like to create some visualizations (using reagent
). What's the best way of syncing a r/atom
to a query in my in-memory db in your opinion?
To be more clear, I'd like that when I do a transaction, the query that powers a r/atom
is redone, so that redrawing is triggered on the js side
There’s currently no hook for a transaction to execute code when it’s done. Typically, I’ve created my own transaction function to wrap the central one, though I know that doesn’t always work.
At this point, I would recommend putting a watch on the Connection state field (which is an atom)
The state atom contains a map with 2 values:
{:db latest-db-value
:history [...]}
The history is an array of all the previous DB valuesI realize that this is unsatisfactory. It’s incentive for me to add a transaction function post haste
Anyway, every call to transact
will lead to this atom being updated. The :db
value will change to have the updates in it, and the :history
value will grow 1 longer
This will take more effort than a simple hook, but would you be interested in seeing this whole API? https://docs.datomic.com/on-prem/reference/database-functions.html
thank you so much for the explanation @quoll! In my case I can probably work around the problem with a watch as you suggested. I mostly don't want to cause any urge since I know that you're not working on this directly in these days. Ideally from the API you linked I really like having the possibility to specify checks and constraints, but I'm not very familiar with it - watching the video now :)
https://www.youtube.com/watch?v=8fY687k7DMA which was linked in the page you suggested
it's a very nice idea, and I didn't realize that asami tends to the same API of datomic! Neat!
anyway, if you ever end up implementing the hook feature ping me - also, if you want to pair on the issue I'm up for it
w/ datascript you can eschew the whole “conn” and just use db-with
which returns a new db value. this way you can store it in your own container, like a reagent ratom
I can’t do that with persisted databases though. (well, I could, but that would create a branch, and I have no idea how to resolve branches!)