Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only reaches root element #1

Closed
jdf-id-au opened this issue Apr 21, 2022 · 2 comments
Closed

Only reaches root element #1

jdf-id-au opened this issue Apr 21, 2022 · 2 comments

Comments

@jdf-id-au
Copy link
Owner

May need to create custom lifecycle cljfx/cljfx#161

@jdf-id-au
Copy link
Owner Author

Simply putting datalevin store atom in cljfx context seems to work... access it with fx/sub-ctx to do query:

(ns simpler
  (:require [datalevin.core :as dtlv]
            [cljfx.api :as fx]
            [clojure.core.cache :as cache]))

(def *store (dtlv/get-conn "path" schema)
(def *context (atom (fx/create-context {:dtlv *store} cache/lru-cache-factory)))

(dtlv/listen! *store :ui (fn [_] (swap! *context fx/swap-context assoc :max-tx (:max-tx @*store))))

(defn q [ctx query-vector]
  (let [_ (fx/sub-val ctx :max-tx)] ; make sub depend on :max-tx to provoke rendering
    (dtlv/q query-vector @(fx/sub-val ctx :dtlv)))

Let's see how this goes...

@jdf-id-au
Copy link
Owner Author

Repo updated reflect this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant