Fork me on GitHub
#om
<
2016-02-07
>
joshg01:02:43

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?

Kamuela01:02:05

App state lives in a single atom as a map of key value pairs?

Kamuela01:02:12

Did I get all or part of that right?

Oliver George01:02:47

Quick shout out to @jannis who is posting some beautiful code on github using om.next

Oliver George01:02:23

After looking at the kanban demo I was tempted to poked around his other repos. https://github.com/Jannis/

jannis07:02:39

@olivergeorge: Thanks for the praise simple_smile 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! 😉

hueyp09:02:29

anyone know why I’d get “No queries exist for component…” : https://gist.github.com/eyston/89f1d4b883cc1c293dda

hueyp09:02:45

the meta path and query are correct for the child

hueyp09:02:33

if I make up a keyword instead of ident it doesn’t complain 😕

hueyp09:02:57

but I mean … I should be able to use idents in a root query no?

anmonteiro12:02:12

@hueyp: I don't think they are supposed to work

anmonteiro12:02:33

Your queries must match the shape of your state

drcode15:02:19

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!

anmonteiro16:02:10

@drcode: in short, you should also defonce the reconciler

anmonteiro16:02:34

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/

drcode16:02:55

Thanks @anmonteiro very helpful, that post is exactly what I needed!

hueyp17:02:11

@anmonteiro: the parser / data works fine … the app-state is : {:person/by-id {2 {:id 2, :name Erik}}, :om.next/tables #{}}

hueyp17:02:24

and it renders the data, the path-meta is set, etc

hueyp17:02:08

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

hueyp19:02:25

anyone have examples of routing using set-query?

hueyp19:02:56

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

hueyp19:02:58

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

hueyp19:02:56

in my mind you could pass down context from the root … like (om/get-query Friends {heres-some-route-infos})

jannis19:02:47

@hueyp: You can, sort of. ({:friends (om/get-query Friends)} {:param1 val1 :param2 val2...})

hueyp19:02:31

I was wondering if this had any use in (query …)

hueyp19:02:48

oh nvm I misread

hueyp19:02:18

so now the parser is doing the routing?

jannis19:02:06

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.

hueyp19:02:45

thanks, I’ll take a look simple_smile 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?

hueyp19:02:57

I should read your example before asking questions 😜

hueyp20:02:58

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

hueyp20:02:43

e.g. I focus it along the path [[:person/by-id 2]], but focus->path gives back [:person/by-id] as the focused path

hueyp20:02:08

which then om full-query gives an exception

hueyp20:02:33

focus->path just drops the second part of the pair

hueyp20:02:26

so this works fine for stuff like [:current-user _], but not so much [:user/by-id 1] 😜

jannis20:02:12

[:current-user _] is not a regular ident.

jannis20:02:14

It's special-cased in the parser as being a read at the root level of the query (IIRC)

hueyp20:02:37

my understanding of the documentation is that if any ident is encountered in a query, its parsed from the root

hueyp20:02:02

I have zero idea if that is a bug or not

jannis20:02:12

I have no idea either. However, the first lines you pointed at do special-case [:foo _] and that means different behavior.

hueyp20:02:27

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” 😛

hueyp20:02:56

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

cjmurphy20:02:14

Is it Idents or fact that you are changing the queries (so it is not a static setup), or a combination of these two?

hueyp21:02:15

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

hueyp21:02:39

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]}]

currentoor23:02:18

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.

currentoor23:02:33

Is there an example of the complete source for this tutorial?