This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-12
Channels
- # aws (21)
- # aws-lambda (8)
- # beginners (53)
- # boot (56)
- # braveandtrue (1)
- # cider (49)
- # cljs-dev (8)
- # cljsjs (1)
- # cljsrn (57)
- # clojure (403)
- # clojure-austin (17)
- # clojure-dusseldorf (10)
- # clojure-greece (9)
- # clojure-spec (57)
- # clojure-uk (144)
- # clojurescript (60)
- # datomic (149)
- # docker (1)
- # emacs (1)
- # hoplon (23)
- # humor (1)
- # jobs (1)
- # leiningen (2)
- # luminus (1)
- # off-topic (1)
- # om (24)
- # om-next (15)
- # onyx (23)
- # protorepl (2)
- # re-frame (58)
- # reagent (90)
- # remote-jobs (1)
- # ring-swagger (4)
- # slackpocalypse (1)
- # spacemacs (2)
- # specter (18)
- # untangled (4)
- # vim (1)
- # yada (27)
hey everyone, i am wondering if there is a way to build a query that uses the results from one part of the query as the parameters to the next part of the query. i'm doing this with remote queries. here's an example: [:learn/active (:learn/sections ACTIVE-ID)]
so :learn/active will fetch the active id from remote, then learn/sections will take that id as a param and call the remote again to get the sections?
@azzikid run the first query and in componentWillUpdate look for changes in the properties (see if your remote data has arrived), if yes, then either use om/update-query! or om/set-query! to trigger a new read with new query.
Was thinking if it would make sense if the parser had the ability to control the merge function, many remote queries merge differently in some of my apps, that {:value/:action :remote :merge} would sound nice, but the drawbacks could be worse than the benefits of this setup.
new issue i have is that i am getting the error: No queries exist for component path ... my root component query has [:app/learn (om/get-query Active) (om/get-query Sections)]
. the error occurs when changing the params in the Sections component with update-query! after componentWillUpdate is called.
@azzikid if you used set-query! did you remember to merge all the existing queries you wanted to stay? this is bit like atomic reset!
(om/update-query! this (fn [{:keys [query params] :as q}]
(assoc q :params new-params))
here's a gist with the components: https://gist.github.com/johnomarkid/c1cff90088418cdc8994440cd1b4580b
doesn't look like the query parameter inside the following query ({:learn/sections [:learn/sections]} ?pouchq) is doing much, it's outside of the join and not a parameter. But these No queries exists errors are most of the time caused by inconsistency of the root component and a child component. So look trough the queries in the root component and if the methods in the parsers are correctly setup (ex if the data is normalized/vectorized or not)
I'm having trouble with a read method... I'm fetching a list of items with params to filter/limit the results. If I include both :remote and :value keys in the map I return, i get two remote requests. I'm not sure how to know whether I want to return the list from state or from remote...How do I know if params/resultset has changed?
If i change the search param, I end up in an infinite loop...remote call, merge, remote call, merge, remote call..
I can't just test to see if the key is in state, because it could be there but it can be the resultset from a previous query with different params...
My only idea is to update the params with some unique key every time i update the query...and then i can check if this matches the last one
Think that it might just be how I designed the components to update the params actually, entering into render loops
Yeah, resolved it with something like this
(componentDidUpdate [this prev-props prev-state]
(when (and (not= prev-state (om/get-state this)) (= prev-props (om/props this)))
maybe i can redesign things to be more logical...
@azzikid I also had now for 15 minues a battle with No queries exist on path. And strangely by not passing properties into component C from B in A->B->C structure fixed it. Sometimes I feel like I don't know anything about om.next.
Are there any emergent resources on mastering read and mutation functions?
hey everyone, I just stumbled upon this article and I realized I can probably use this a lot https://facebook.github.io/react/docs/higher-order-components.html (edited) is there “a good way/recommended way” to do this in om-next?