This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-07
Channels
- # beginners (4)
- # boot (186)
- # cider (68)
- # cljsjs (2)
- # cljsrn (6)
- # clojure (103)
- # clojure-dev (1)
- # clojure-russia (117)
- # clojurescript (40)
- # community-development (31)
- # cursive (2)
- # data-science (7)
- # datomic (6)
- # devcards (2)
- # editors-rus (2)
- # emacs (2)
- # jobs (2)
- # ldnclj (2)
- # lein-figwheel (41)
- # off-topic (5)
- # om (50)
- # overtone (2)
- # re-frame (36)
- # reagent (1)
- # spacemacs (3)
- # yada (2)
When writing a server for Om Next, should queries use GET and mutations use POST? Is there a non-trivial server example? Is the om-next-demo a good example to use?
Quick shout out to @jannis who is posting some beautiful code on github using om.next
After looking at the kanban demo I was tempted to poked around his other repos. https://github.com/Jannis/
@olivergeorge: Thanks for the praise I'd like to point out that most of the other repos are experimental at this point. Props to everyone who finds the time to actually finish stuff! 😉
anyone know why I’d get “No queries exist for component…” : https://gist.github.com/eyston/89f1d4b883cc1c293dda
@hueyp: I don't think they are supposed to work
Your queries must match the shape of your state
Hi, I'm a little confused on how to use normalized state with figwheel reloading... so I have (defonce app-state (atom ...))
to make figwheel retain state on reloading and :normalize true
on my reconciler, so everything works great when I reload my page. But the problem is if I update a source file, figwheel tries to re-normalize my already-normalized state, and bad things happen.
Questions: Is normalization meant to be idempotent? (i.e. you can normalize already-normalized state without errorrs... I suspect the answer is "no, you should only normalize things once.") If not, is the correct solution to this problem to do (defonce reconciler ...)
as well? Thanks!
@drcode: in short, you should also defonce
the reconciler
I've written about reloadable code & Om Next. Here's the link, if you're interested: http://anmonteiro.com/2016/01/writing-om-next-reloadable-code-a-checklist/
Thanks @anmonteiro very helpful, that post is exactly what I needed!
@anmonteiro: the parser / data works fine … the app-state is : {:person/by-id {2 {:id 2, :name Erik}}, :om.next/tables #{}}
I’m thinking of the use case of a route like /user/{id}
… not sure how else to handle that then querying directly by ident
I’m thinking of a route like /user/friends/{friend-id}
… I’m not sure how I can call set-query
on the root, but kind of cascade route params from top to bottom
like if your component path is ’(Root Friends Friend)
, each of their queries depends on the route, but you wouldn’t want to call set-query
on each of them
in my mind you could pass down context from the root … like (om/get-query Friends {heres-some-route-infos})
@hueyp: You can, sort of. ({:friends (om/get-query Friends)} {:param1 val1 :param2 val2...})
@hueyp: One example of how I've done routing is via https://github.com/Jannis/custard/blob/master/src/web/routing.cljs#L29
In that example bidi's router translates URLs to an app state / set-query
calls. And it also supports translating app state back to a URL that is then set in the browser (via activate-route!
). It's not ideal because in my solution, all app data is queried regardless of which route is active. But that could be changed by changing more than the query params in navigate-to
.
thanks, I’ll take a look yah, I was kind of thinking the
query
function could be dependent on state and only return the active query … but you can’t really accomplish that, right? like that logic of route->query needs to live outside the component?
regarding my “No queries exist for component path…” … it appears when you focus a query along a path with an ident, it works fine, but when you ask for the focus path, it returns something else
e.g. I focus it along the path [[:person/by-id 2]]
, but focus->path
gives back [:person/by-id]
as the focused path
It's special-cased in the parser as being a read at the root level of the query (IIRC)
my understanding of the documentation is that if any ident is encountered in a query, its parsed from the root
db->tree
does a check on the ident : https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L1294-L1298
but focus->path always ignores the second part: https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L202
I have no idea either. However, the first lines you pointed at do special-case [:foo _]
and that means different behavior.
yah, I’m wondering if that same check on _
is required in focus->path
… made an issue : https://github.com/omcljs/om/issues/605 … might just be “don’t do this” 😛
I feel like idents are my main struggling point … they seem like the main concept for keeping things consistent, but I keep hitting issues thats stopping me from really understanding
Is it Idents or fact that you are changing the queries (so it is not a static setup), or a combination of these two?
naw, two separate things … I’m way more interested in idents and how they work … the dynamic query stuff is a curiosity of how I’d do routing in om.next
I’m coming from relay / graphql … so I have baggage of wanting to query by ident … e.g. query { node(id: 2) { id name } }
=> [{[:node/by-id 2] [:id :name]}]
https://github.com/omcljs/om/wiki/Remote-Synchronization-Tutorial Has anyone recently gone through the remote sync tutorial? I copied and pasted the examples directly into my file and still can’t it to work.
Is there an example of the complete source for this tutorial?