This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-29
Channels
- # aws (8)
- # babashka (45)
- # beginners (83)
- # cider (23)
- # clj-on-windows (4)
- # cljdoc (23)
- # clojars (6)
- # clojure (68)
- # clojure-dev (33)
- # clojure-europe (75)
- # clojure-nl (1)
- # clojure-uk (4)
- # clojurescript (14)
- # conjure (6)
- # data-science (15)
- # datascript (7)
- # datomic (47)
- # docker (15)
- # events (1)
- # fulcro (4)
- # graphql (3)
- # jobs (4)
- # lsp (14)
- # nginx (2)
- # nrepl (2)
- # off-topic (41)
- # pathom (18)
- # pedestal (1)
- # polylith (72)
- # reitit (8)
- # reveal (1)
- # shadow-cljs (48)
- # tools-build (11)
- # tools-deps (24)
- # xtdb (8)
Hi, can anyone here confirm that re-posh (Posh) does not pick up on DB changes when the part of the query that changes is a reverse reference lookup (like :_selected
)?
UI reloads triggered by e.g. shadow-cljs confirms that my code actually works, so the issue is that re-posh does not automatically refresh my UI component that relies on such a reverse lookup.
I attempted to work around it by adding a :db/tupleAttrs
with the reverse lookup, but it ends up as nil so I guess Datascript doesn’t support that.
Any ideas before I rewrite to something less elegant?
The general idea here is that I have a UI listing of Datascript entities and want to highlight the one that is currently pointed at by :selected
ref on a “special” focus entity.
UPDATE: Abandoned the concept of referencing the selected entity and instead resorted to move a :selected? attribute around as a token. Still interested in the general feasibility of using reverse references in re-posh queries if anyone has some insight.
It should be possible to fix this in Posh; I'd suggest raising an issue here: https://github.com/denistakeda/posh/issues
There were some known issues along these lines on the original mpdairy fork, and my sense was that denistakeda had fixed up a few of them, but there may be more.
Can confirm that :db/tupleAttrs
is not supported yet, though I think tonsky has considered doing this. I can say that #datahike does have this, and there was at least at one point a hope that posh could be agnostic as to the backend store (even running on datomic server side as an option), but I think it may have still involved some "glue code" to get this sort of thing to work, and I'm not sure what denistakeda's plans with all that are.
Good luck!
PS It is also possible to specify a manual update pattern to force the query to update on a broader set of fact patterns (even on every tx), so that's one escape hatch you could use for now.
Thanks for all the input @U05100J3V, I need to research that manual update pattern for future “emergencies”.