Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 12 2021 12:30
    fahtative commented #26
  • Sep 12 2021 12:17
    fahtative commented #26
  • Sep 12 2021 12:17
    fahtative commented #26
  • Sep 12 2021 12:13
    fahtative commented #26
  • Sep 12 2021 12:01
    fahtative commented #26
  • Sep 12 2021 12:01
    fahtative commented #26
  • Sep 12 2021 11:59
    fahtative commented #26
  • Sep 12 2021 11:59
    fahtative commented #26
  • Nov 30 2020 19:39
    metasoarous closed #34
  • Nov 30 2020 19:39
    metasoarous commented #34
  • Nov 16 2020 05:16
    metasoarous commented #34
  • Nov 14 2020 12:15
    jpmonettas commented #34
  • Nov 14 2020 12:14
    jpmonettas synchronize #34
  • Nov 14 2020 00:59
    metasoarous commented #34
  • Nov 14 2020 00:58
    metasoarous commented #34
  • Nov 14 2020 00:57
    metasoarous commented #34
  • Jul 22 2020 12:14
    jpmonettas commented #34
  • Jul 21 2020 21:34
    metasoarous commented #34
  • Jul 11 2020 13:34
    jpmonettas synchronize #34
  • Jul 07 2020 12:12
    xlfe commented #35
javier abanses
@nrfm
@metasoarous @alexandergunnarson got it compiling now.
Christopher Small
@metasoarous
Oh! Great! What was the deal?
javier abanses
@nrfm
that aget call missing an argument was breaking compilation. I just fixed that and compiles ok with some warnings that i am looking into now.
Use of undeclared Var posh.lib.ratom/array at line 202 src/posh/lib/ratom.cljc is an example.
they seem to originate from the if-cljs macro. investigating now, need some coffee to un-bend mi mind :)
Christopher Small
@metasoarous
Ah; I see. Good catch; Thank you!
Heh; macro recovery
javier abanses
@nrfm
@alexandergunnarson @metasoarous how do i go about running the tests? I have never run tests in cljc and when running lein test all the tests get run for clojure ok, but the ones in :cljs conditionals get ignored. thanks!
Christopher Small
@metasoarous
@nrfm I haven't done any testing with posh; I would check with @mpdairy. He hasn't been working with the library so much lately, but I believe he set up all the testing stuff.
javier abanses
@nrfm
@metasoarous thanks!
Brian Marco
@bamarco
Anybody that was interested in a rum plugin I wrote a potential roadmap here: mpdairy/posh#27
Matt Parker
@mpdairy
@nrfm Hey, I never set up any tests, @alexandergunnarson set up some for his ratom stuff. I don't think they cover much of posh though
Christopher Small
@metasoarous
@mpdairy Thanks!
Brian Marco
@bamarco
@mpdairy @metasoarous I'm trying to understand how the graph is related to the pull analysis. Could somebody explain the basic strategy for how the caching is done? I want to know if I can do the same thing with an onyx compute graph without state (or less state). Like if I have a tx-report can I decide which ratoms should update directly?
Christopher Small
@metasoarous
The graph structure has a cache of active queries, and on transaction, it goes through all the queries and runs a pattern match against the cached structure, and decides whether to rerun the actual query. I don't recall the details of how things are structured though.
If you do some pprints as things flow through, you should get a better sense though.
Brian Marco
@bamarco
That sounds like I could then. I want to stop all the listener business and subsume that into the compute graph. And I might be able to pass the cache as a value too if I can't drop it entirely. Not sure if it's worth the time at this phase.
javier abanses
@nrfm
@mpdairy thanks!
Baruch Berger
@bbss
I'm trying out posh, but getting an error when using pull:
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)
maybe this warning I get during compilation has something to do with it:
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
Brian Marco
@bamarco
@bbss Can you show your call to pull in your code and your ns?
Baruch Berger
@bbss
@bamarco sure, thanks
(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..]))
Baruch Berger
@bbss

and

(def db
  (d/create-conn {:translated/english {:db/cardinality :db.cardinality/many
                                       :db/valueType :db.type/ref}
                  :translated/korean {:db/cardinality :db.cardinality/many
                                      :db/valueType :db.type/ref}}))
(posh! db)

for what it's worth. That doesn't throw though.

Brian Marco
@bamarco
@bbss posh calls to pull and q take the whole conn not just the db. Try removing the derefs. So it says db instead of @db
Baruch Berger
@bbss
@bamarco yes, forgot to change it back, I tried like that initally. Same problem.
Brian Marco
@bamarco
@bbss You also need to 'deref' the pull call itself. So @(pull ...)
Baruch Berger
@bbss
well the error already occurs when calling pull
Brian Marco
@bamarco
Do you have a pull by itself? Because you are immediately calling a keyword property on the result.
Baruch Berger
@bbss
no, the pull didn't succeed, this would work with a normal pull though.
Brian Marco
@bamarco
Posh pull returns a ratom not an entity.
Baruch Berger
@bbss
yes, I understand that. But posh pull is the thing that errors so we aren't there yet :D
Baruch Berger
@bbss
but your point about taking the conn, not just db makes me think maybe it's got something to do with devcards
Brian Marco
@bamarco
That's all I got. Good luck though. :smile:
Baruch Berger
@bbss
Okay, thanks for the input :D
posh looks pretty awesome :)
was doing a kind of full rerender approach before, but I think reactive q and pulls will be a lot cleaner/faster
Brian Marco
@bamarco
Yeah, it def cuts down on reloads.
Baruch Berger
@bbss
Hmm, I don't get the same error anymore. I think it's because of the order in which I required..
λex Vincent
@alexisvincent
Hi guys :D Awesome awesome lib. Was wondering how you managed to extract datoms relevant to a query? I can’t seem to find a way to do it and cant quite grok where its happening in the posh codebase
Matt Parker
@mpdairy
hi @alexisvincent thanks! I don't remember exactly, but basically I had to come up with a bunch of rules for various scenarios in 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.
λex Vincent
@alexisvincent
@mpdairy Thanks! Although I’m particularly interested in extraction at query time. So how do you retrieve the initial set of datoms? Trying to work out if a similar aproach can be used to get initial datoms from a datomic database for sync
Matt Parker
@mpdairy
@alexisvincent Oh yes you could use that initial set of datoms to sync with datomic. if you call 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.
to get the actual query results with the :find constraints, it just runs q on the set of possible vars (not the whole db), so it should still be pretty fast
λex Vincent
@alexisvincent
Hmm. That’s clever! Thought you might have figured out a way to it with one query. Pull is a bit more complicated though..? I was wondering about an approach that constructed a filter database specifically for the query and then just saved Datoms it encountered to a set
The catch set might be too large though
Matt Parker
@mpdairy
I think with pulls all the relevant datom info is already in the result of the pull results, so you just have to traverse it and pull out everything as individual EAV datoms.
Have you looked at the Datsync project? They've been working on syncing between datomic and datascript for a while now. I don't know how it's going, but they are active at least.
Oliver Rolle
@orolle
@mpdairy Does posh have the same performance characteristics as rum + datascript? I have read that datascript causes lags in the UI when the database is large (browsers UI thread is blocked)? Is it an option to run a datascript query within a web worker?
Matt Parker
@mpdairy
@orolle Posh should be faster because it doesn't make full queries or pulls every time there is a new transaction, only when a new tx will change the result of a pull/query (this is assuming we're comparing it to a rum + raw datascript that redoes all its pulls/queries every tx). In posh, pull is more efficient than q, so you might be able to get away with a large ui if you use mostly pulls.
i'd just recommend doing some testing before you commit to using it
Oliver Rolle
@orolle
@mpdairy Thanks. I will try it out.
Álvaro Castro-Castilla
@alvatar
Hi @mpdairy, could you provide some pointers on how to use Posh with Rum, please?