Hi @vlaaad, I have a subscription that looks like this:
(defn sub-current-page
[context]
(println "fire!")
(let [db (fx/sub context :db)
eid (fx/sub context :eid)]
(d/entity db eid)))
The :db
key contains the latest value of a https://github.com/replikativ/datahike/ database, which I swap!
to the latest db value every time a transaction occurs. (Based on your example of the datascript db). However, the subscription only fires when :eid
changes, not when :db
changes. Any ideas why this could be happening?
Also let me know if youโd rather get these questions as GH issues ๐Either way to ask is fine ๐
Could it be that datahike returns true for (= old-db new-db)
?
At least I know it has these kinds of problems in it's entity API
which defines equality only based on id, but not db, which is very very wrong...
@jlmr ^
Thanks, will look at that. Youโre probably right
Hm:
(defn transact
[conn tx-data]
(let [report (d/transact conn tx-data)]
(swap! *context fx/swap-context assoc-in [:db] (:db-after report))
(= (:db-before report) (:db-after report))))
Returns false
for any transactionOk changing the subscription to this:
(defn sub-current-page
[context]
(let [db (fx/sub context :db)
eid (fx/sub context :eid)]
(d/pull db '[*] eid)))
Fixes it!