Fork me on GitHub
#om
<
2017-01-11
>
alex-glv04:01:58

@ag I think I am struggling with the same issue. First, I have :route/data for my Root component, that then based on active route parser the corresponding components’ query. But I never get my data normalised. Just today I realised that my component needs to be at the top level in the graph, I can’t have it nested deeper. I would appreciate someone more experienced to write a short blog on when it’s expected to have normalized / non-normalized data.

danielstockton08:01:40

Can anyone share how they handle a 'detail view' (/users/123) i.e. get the route-params from the app-state and somehow pass that to the component query? I'm using compassus and pulling :route/params out of app-state in my Wrapper component, but i'm not sure how to pass it through to the view component query.

alex-glv09:01:28

Anyone can suggest why this

Uncaught Error: Union components must implement Ident
is thrown? How do I find out which component fails to implement ident, and why does it have to?

danielstockton09:01:17

@alex-glv did you recently implement a union query somewhere (probably a component that displays heterogenous types.

danielstockton09:01:25

They need an ident or the components don't know what to pull out of the list

alex-glv09:01:19

Ah cheers @danielstockton , I added :normalize true, now need an ident as per tutorial

mavbozo09:01:24

that's strange. I have a component which have union query and its child component don't have Ident

mavbozo09:01:39

and I never see that error

alex-glv09:01:12

@mavbozo maybe you don’t have

:normalize true
in reconciler? That’s when it appeared

mavbozo09:01:18

well, I don't have :normalize true in my reconciler options

danielstockton09:01:05

if you're doing normalization yourself, it leaves it up to you whether you use the ident or do it some other way

alex-glv09:01:36

@danielstockton Ah I see, so, if the query of a component is of sort {:some/key […]} then that component should implement ident? And you’re correct, I was doing the normalization myself until I decided to see what happens when I don’t.

danielstockton09:01:02

yep, if using the default normalization

tmulvaney11:01:07

@danielstockton I have a bidi route mapped to : which sets params. I have a component which compassus mounts when : is the route. That component PostShow has a query: [{:post/show [:post/title ...]}] and a read method which looks something like: {:value (om/db->tree query [:post/by-id (get-in state [:params :id])])}

tmulvaney11:01:31

I think that would translate to your user show scenario

danielstockton11:01:54

thats the part i was missing, the read method

danielstockton11:01:59

everything else is the same, thanks

tmulvaney11:01:17

ok I missed the extra state at the end of db->tree

tmulvaney11:01:24

but it should work for you

danielstockton11:01:28

i suppose this means that you load all the posts in advance?

danielstockton11:01:41

but i can change my read method to load them on demand

tmulvaney11:01:03

Yeah the index view is the posts list. But I guess you could have a remote on :user/show

jannis12:01:51

@dnolen @anmonteiro Would you be interested in relaxing the language spec for parameter maps or perhaps even developing it further? In a product I’m working on, we’ve adopted the Om Next query language in other parts of the system, as well and have found two extensions of parameter maps extremely useful: 1. Use variable paths (e.g. [?user ?db/id] in ({:user [:user/name]} {:db/id [?user ?db/id]})) to bind to values deep inside the params (in this case they could be {:user {:db/id <id>}}). 2. Use parameter paths (e.g. [:user/account :db/id] in ({:users [:user/name]} {[:user/account :db/id] ?account-id}) to express such things as “query only the users who belong to the account with ID <id>. 1 is something Om Next would have to do when binding params. I could provide an implementation for this — if you’re interested. 2 is something that’s really up to read implementations. It could be supported without any extra effort in Om Next by relaxing ParamMapExpr := EdnMap(Keyword, EdnValue), replacing Keyword with something more flexible. I checked the code and nothing seems to be enforcing parameter names to be keywords at the moment anyway. Would you be up for relaxing this?

dnolen12:01:53

@jannis that’s interesting but need to think about that one

jannis12:01:20

Sure. I’m happy to discuss improvements or problems of the idea whenever you want. 🙂

Yehonathan Sharvit13:01:59

I have a weird issue with om.next and klipse

Yehonathan Sharvit13:01:07

klispse uses om.next

Yehonathan Sharvit13:01:08

Now, when I’m evaluating code - inside klipse - that loads react, it seems that om.next remounts everything

Yehonathan Sharvit13:01:35

You see the container on the left is updated by the code on the left

Yehonathan Sharvit13:01:54

But then when react is loaded, the component is remounted and goes back to its insitial state

Yehonathan Sharvit13:01:24

I have tried to make shouldComponent => false but it didn’t help

Yehonathan Sharvit13:01:05

With the debugger and a few printings to the console, I have discover that componentDidMount was called again after react is loaded

tmulvaney13:01:12

That link just has a HelloWorld in blue. Is it the right one?

Yehonathan Sharvit13:01:00

Oh! On my computer it is blue for a short time and then back to the original state

tmulvaney13:01:19

Click on the link. I think its missing code

anmonteiro13:01:31

@viebel I get your behavior too

anmonteiro13:01:44

I'm not sure this is a Om Next issue

anmonteiro13:01:06

hrm.. you might have to keep track of which libraries are already loaded in the environment

anmonteiro13:01:30

React wants to control the DOM, and you're changing it yourself

anmonteiro13:01:54

but then you require React again, and it takes control over the DOM again

anmonteiro13:01:26

what I would try to do is ignore the (require 'cljsjs.react) call, because your environment has already loaded it

Yehonathan Sharvit13:01:59

@anmonteiro I was also thinking of preventing react from being load twice - this will probably solve the issue

anmonteiro13:01:04

@viebel right, not only React, but every foreign library that Klipse has already loaded to its environment

Yehonathan Sharvit14:01:57

Im already doing it. But not with cljsjs packages yet..

Yehonathan Sharvit21:01:34

Thx for your tip @anmonteiro. Now it works fine

Yehonathan Sharvit21:01:08

You can even run om.next code inside klipse (that is built with om.next). Live demo: http://app.klipse.tech/?container&amp;cljs_in.gist=viebel/69a7c0cdf289bad342fefe82fdeb7179