This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-15
Channels
- # admin-announcements (3)
- # aws (1)
- # beginners (1)
- # boot (73)
- # cider (1)
- # clojure (146)
- # clojure-japan (4)
- # clojure-nl (3)
- # clojure-russia (90)
- # clojurescript (72)
- # community-development (17)
- # core-async (10)
- # cursive (60)
- # datomic (15)
- # devcards (7)
- # emacs (5)
- # events (5)
- # hoplon (3)
- # instaparse (3)
- # ldnclj (48)
- # leiningen (5)
- # off-topic (27)
- # om (120)
- # onyx (31)
- # re-frame (7)
- # reagent (7)
- # ring-swagger (17)
- # yada (3)
can someone help me to get the mutation right? https://gist.github.com/ThomasDeutsch/d54135ebcdad5c9f3d89
hey @dnolen, if I have a root component that renders two subcomponents with their own queries, is this an idiomatic way to write the root query, or is there a better way?
(defui Root
static om/IQuery
(query
[this]
(vec (concat
(om/get-query Sub1)
(om/get-query Sub2))))
Object
(render
[this]
(let [props (om/props this)]
(sub-1 props)
(sub-2 props))))
@adamfrey: how about static om/IQuery (query [this] [{:sub-1 (query Sub1) :sub-2 (query Sub2)}])
, and then render using (sub-1 (:sub-1 props))
etc?
@sander: I tried that earlier and that sends the :sub-1
key to be read from my state, so my props end up as {:sub-1 :not-found}
@adamfrey: queries where you don’t know the name of the key in the component that passes along the info is not idiomatic.
this occasionally means you will need a couple of forwarding entries in your parser, but this is no big deal IMO
@thomasdeutsch: 1) in that code :state
is a DataScript instance 2) no 3) need an actual question
thank you @dnolen. the actual question is: when i start a om/transact! i get this error message:
clj {:message "No queries exist for component path (om-datascript.core/CounterList om-datascript.core/Counter)", :data {:type :om.next/no-queries}}
and i do not know what my mistake is 😐 The gist: https://gist.github.com/ThomasDeutsch/d54135ebcdad5c9f3d89@thomasdeutsch: right the error is telling you there is no valid query for where that component lives
Will need to think about how to make it clear there has to be a one to one correspondence
so, this is not correct? `[{:app/counters [{:counter-list/items ~subquery}]}]
ok, i understand. right now, i think of a way to change the query ... thanks for the help!
@thomasdeutsch: so this is good feedback, I think I will probably allow your query to work
as i understand it now, i need to get the :counter-list/items out of the query. for this i need to write a read method for the counter component? ... hard to get my head around it at the moment.
@thomasdeutsch: well besides the actual problem you found, I don’t really understand why you are going about this the way you are.
You’ve modified the DataScript tutorial in such a way that I do not understand your goals.
in my example, i simply added a root component, to host 2 counters - that is all.
@thomasdeutsch: right but the :app/counters
read doesn’t make sense.
thanks, this is a great feedback. i do not know why i used :app/counters in my example. I think it is simply because of the read method. i need to wrap my head around this.
well I used :app/counters
in my tutorial, I’ll probably change that if it continues to be a source of confusion for people.
as soon as it "clicks" for me, i will give a short feedback what caused the confusion in my case.
@thomasdeutsch: there’s another bug https://github.com/omcljs/om/issues/416
this is specific to DataScript and other local custom stores that can actually support Pull
@thomasdeutsch: in anycase, my assessment is that there’s nothing actually wrong with your code
any (early) ideas already about how to prerender om.next components on the server? right now i'm thinking, just like in om.current, about using ReactDOMServer.renderToString in a nodeJS process, and making sure the generated html includes initial transit/edn for the client-side local cache. (not sure if my formulation makes sense)
I get Uncaught TypeError: React.initializeTouchEvents is not a function after upgrading to alpha2
@bbss: doesn’t sound like an Om thing, I just bumped to React 0.14 so you’ll have to sort out any React issues that may have caused.
@sander pre-rendering is definitely a React level concern, Om doesn’t provide anything in this regard over React
@sander some people have gone the Node route others Nashorn. IMO, it’s just more effort than it’s worth
@dnolen: Updated to alpha2 and now get ‘Cannot read property of add of null’ with this line from the transact* function: (.add (:history cfg) id @(:state cfg))
@dnolen: Hmmm. I did ‘lein clean’ and wiped out target directory, and still getting error. Is there something else I need to clean up? I am using devcards, if that might be a problem.
@dnolen: unfortunately, that wasn’t it. Got same error outside of devcards. I’ll keep messing with it.
Is it because of issue #416 (DataScript pull queries return results without data paths meta) , that after a mutation, the query from the sub-component is used? https://gist.github.com/ThomasDeutsch/7d153c6192f41dbbc75e
when i not have a :default reader, i get this error:
Error: No method in multimethod 'om-datascript.core/read' for dispatch value: :db/id
@thomasdeutsch: You're Counter
component is querying :db/id
:counter/title
:counter/count
for the keys you'll need to wrap the query into something like {:app/counter [:db/id :app/title :app/count]}
and pass the Counter
id is as a parameter
Thanks!
any "top" level keys in a query (i.e. [:id {:post [:title :body]}]
has :id
and :post
as top level keys) are the dispatch values for the parser multimethods if you're using om/dispatch
as the dispatch function
oh, i get it. in my case, i have 2 counters. do i need to implement om/Ident for every counter, go get the id for the counter query?
om/ident
is only for the case where you're using an atom as a datastore. You'll need to get the id for each counter
as far as i understand: on the first render, everything is passed down from the root. when i mutate an entity, the child will render again, but at this point, i do not know where to get the identity from....
... you say that i have to pass the counter id as a parameter - but when the component rerenders, i do not know where to get the id from - i need to look into it a bit more.
Try adding this to your counter component
static om/IQueryParams
(params [this]
{:id (:db/id (om/props this))})
that should give you the datascript id as a query parameters when the rerender query gets run@thomasdeutsch: the fixes I just made make your earlier gist work as it should have
Hey all, I am using alpha2 with the om.next quick-start. When I get to the first “Naive Design”, where the reconciler is being introduced, I get “Cannot read property ‘render’ of undefined”. I am copying and pasting the code into my namespace right from the github article. Anyone have any ideas? Did anything change recently to invalidate the quick-start?
I just ran into this. I didn’t do a ‘lein clean’ after updating. @gardnervickers
@gardnervickers: Now I am getting the same thing you are: render of undefined
Yea I’m kinda banging my head on the wall here
It was working for me back in 0.9.0-SNAPSHOT, but now when I go to switch back it breaks again 😕
@dnolen: Is there a reason why js/ReactDOM is not present when trying to do the Naive Design of the quickstart with alpha2?
and just released Om 1.0.0-alpha3, thanks to @thomasdeutsch for pointing out some query bugs
@gardnervickers: these problems all sound like dirty build issues
before a deploy I run through a few tutorials, do all the tests, and run against a much less trivial example I haven't yet published that works with Datomic
@dnolen: I just started over, building each folder and file, and ran into the same thing. Pasting the code from the Naive Design section results in the error.
Re: No queries exist for component path
What's the right way to handle heterogeneous lists of things? Since om/IQuery
is static there's no way to conditionally query for different things based on the results of om/props
.
you have to know the query before the application loads - nothing else is going to work for starting up
this is what set-params!
and set-query!
is for. There’s another thing called subquery
which you should use if you know an important query is going to change
you should see cljsjs.react 0.14.0, cljsjs.react-dom 0.14.0 and om 1.0.0-alpha3 in your list of deps
@monjohn: might have been, the parts are moving fast right now so I would stick to the latest
Thanks guys, working for me after update too
I had the js/ReactDOM missing error with alpha3, I think its just how cljsjs packages work where they won't be included in your build if they aren't required. You can fix it by requiring cljsjs.react.dom in one of your required files for now.
@noonian: that’s not the case. om.dom
pulls in both cljsjs.react
& cljsjs.react.dom
. If it’s not working for you there's something wrong with the environment you have setup.
@dnolen: That makes sense. I'm not requiring om.dom (using sablono), but I am requiring om.next which uses js/ReactDOM but doesn't require cljsjs.react.dom.