This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-13
Channels
- # announcements (12)
- # babashka (88)
- # beginners (60)
- # biff (10)
- # calva (56)
- # clerk (9)
- # clj-kondo (5)
- # clojure (70)
- # clojure-austin (3)
- # clojure-conj (2)
- # clojure-dev (69)
- # clojure-europe (53)
- # clojure-nl (1)
- # clojure-norway (28)
- # clojure-uk (1)
- # clojurescript (27)
- # copenhagen-clojurians (3)
- # cursive (10)
- # datascript (1)
- # datomic (10)
- # fulcro (3)
- # funcool (1)
- # garden (7)
- # helix (5)
- # holy-lambda (5)
- # hyperfiddle (39)
- # introduce-yourself (6)
- # jobs-discuss (15)
- # lsp (3)
- # malli (5)
- # membrane (19)
- # missionary (1)
- # nrepl (6)
- # off-topic (44)
- # pathom (17)
- # pomegranate (3)
- # react (7)
- # releases (1)
- # shadow-cljs (39)
- # tools-deps (16)
- # xtdb (28)
I have a situation where I'm using biff/submit-tx
to update a user and then biff/lookup
to get that user's new data and pop it back into the UI. The problem is, the lookup
is returning the information from immediately before the submit-tx
. It doesn't seem to want to wait for the new info. I tried putting a xtdb/sync
between them, but that didn't seem to have an effect. Even a good long Thread/sleep
doesn't change the situation, but refreshing the page immediately following the completing the form gives me the up-to-date info.
Ooh, I know this one!
biff/lookup
takes a db as input, which is immutable, so if you use the db of the request after a transaction it won't be updated in-place.
What you want is (biff.xtdb/db biff.xtdb/node)
Either that or biff/merge-context
https://clojurians.slack.com/archives/C013Y4VG20J/p1672171409421639?thread_ts=1672171186.302779&cid=C013Y4VG20J
I think, because it's a db, we expect it to always "point" at the latest version but xtdb is bitemporal so it doesn't have to be like that. Its db is actually a snapshot of your state at a certain point in time.
and node is an overarching thing that contains all the snapshots
That's how I understand it anyway 🙂
That makes sense. Especially now that I think back to doing those XTDB tutorials and having to call xt/db
on node
all the time. merge-context
was definitely under my radar. Might have to look at the Biff API with fresh eyes again!
It takes some getting used to but once you grok it I think it's a much simpler model to reason about than relational DBs (where you don't even have any insights about the past).