A luxuriously simple and powerful way to make front-ends with DataScript and Reagent in Clojure.
pprint
s as things flow through, you should get a better sense though.
plugin_base.cljc:77 Uncaught TypeError: Cannot read property 'call' of null
at posh$plugin_base$get_db (plugin_base.cljc:77)
at Function.posh.plugin_base.pull.cljs$core$IFn$_invoke$arity$5 (plugin_base.cljc:127)
at posh$plugin_base$pull (plugin_base.cljc:123)
at Function.posh.plugin_base.pull.cljs$core$IFn$_invoke$arity$4 (plugin_base.cljc:136)
at G__10150__3 (core.cljs:4148)
at G__10150 (core.cljs:4149)
WARNING: Wrong number of args (1) passed to posh.plugin-base/missing-pull-result at line 20 resources/public/js/compiled/devcards_out/posh/plugin_base.cljc
WARNING: Wrong number of args (1) passed to posh.plugin-base/missing-pull-result at line 22 resources/public/js/compiled/devcards_out/posh/plugin_base.cljc
WARNING: Wrong number of args (1) passed to posh.plugin-base/get-db at line 127 resources/public/js/compiled/devcards_out/posh/plugin_base.cljc
(ns korean.cljs.quick-word
(:require
[korean.cljs.training.training-component :refer [typing-field matched-text]]
[datascript.core :as d]
[reagent.core :refer [as-element] :as r]
[posh.reagent :refer [pull q posh! transact!]]
[cljs-react-material-ui.reagent :as ui]
[cljs-react-material-ui.core :refer [get-mui-theme]]
[cljs-react-material-ui.icons :as ic])
(:require-macros
[devcards.core :as dc :refer [defcard deftest]]))
(defn quick-word-component
[state db]
(let [current-typed (r/atom "")
results (r/atom {})
challenge (next-challenge (expression-couples-by-levels db))
show-tip (r/atom false)
[from to] (first challenge)
from-text (:expression/korean (pull @db '[:expression/korean] from))
to-text (:expression/english (pull @db '[:expression/english] to))]
[:div ..etc..]))
q
. A simple case would be where q is looking for [?e :some/attrib ?v]
, then you just look for anytime any transaction with :some/attrib
occurs. The functions for figuring this out are insrc/posh/lib/q_analyze.cljc
. The simpler version is called pattern-from-eav--old
, which is more easy to understand but generates patterns that are much less specific than the query. ("eav" is an entity-attrib-value rule). The more complex function is called pattern-from-eav
and unfortunately it worked really well until we found out it missed one common case, which I couldn't figure out how to fix, so posh is just using the simpler one for now.
q-analyze
with the :datoms
flag you'll get a list of all the relevant datoms for a query, which you could run on the datomic db and then just send all the datoms over to datascript. How the :datoms
thing works, if I remember correctly, is the original query is changed so that instead of returning the stuff specified in the :find
of the q
query, it just returns all possible combinations of the ?
query vars in the :where
eav rules. Then to construct the datoms, it goes through all query eav rules and replaces all the ?
vars with every possible combos.
q
on the set of possible vars (not the whole db), so it should still be pretty fast
pull
is more efficient than q
, so you might be able to get away with a large ui if you use mostly pulls.
hey @mpdairy first of all thanks for the great work that you have done with posh !! that is definitely the missing piece in reactive programming that I was looking for.
I just started working with it and got some errors using pull
. I checked the source code and Cursive
showed me that there are three functions used with less than their declared arguments; namely
posh.plugin-base/missing-pull-result
line 20 and 22posh.plugin-base/get-db
line 127object[TypeError TypeError: null is not an object (evaluating 'new cljs.core.Keyword(null,"conn?","conn?",167224275).cljs$core$IFn$_invoke$arity$1(dcfg).call')]
posh$plugin_base$get_db
cljs$core$IFn$_invoke$arity$5
posh$plugin_base$pull
cljs$core$IFn$_invoke$arity$4
G__10589__3
G__10589
eval code
eval@[native code]
figwheel$client$utils$eval_helper
Since I just started working with posh, I am not sure if this is a problem with my configuration or an actual bug in the implementation, so I wanted to ask you first. I am happy to submit a PR to fix that if you want.
travis ci
for one of my projects. I didnt setup the auto deploy myself but I think that the file is pretty self-explanatory. The only things that you would need to change are the your encripted env vars and your release config in project.clj
. Links below