Fork me on GitHub
#om
<
2016-01-15
>
tmorten03:01:25

Good evening all! Is there a way in om.next to set a query on a component prior to it being mounted? Problem I have is that, when I mount the component, the param is essentially nil and when it tries to fetch the data it obviously doesn't work...should I implement the shouldComponentUpdate and check if param is nil some way?

tmorten03:01:46

OR can I tell my read method to skip the read until a valid parameter exists?

rburns03:01:59

you can set the param value in componentWillMount or componentWillUpdate

rburns03:01:04

the latter isn't called on initial render

tmorten03:01:27

Is it bad to short-circuit the read method if a param is nil?

tmorten03:01:45

That would be easiest... (when param...)

rburns04:01:02

I guess by using set-query! prior to render, you can remove the read in the case of a nil param. don't know if that's a good approach or not

tmorten04:01:01

I'm just thinking if my read method returns nil instead of {:value ...} I'm not going to cause issues down the road?

tmorten04:01:34

It will be called again when set-query! is called with an actual param

rburns04:01:58

yeah, I think a render is triggered in either case, when using set-query! to remove a key, or set a param

tmorten04:01:12

Thanks for the help @rburns

tmorten04:01:55

I'm still trying to figure this all out!

snichme07:01:45

@griff: thats true, so if I want to query just for an ident I have to normalize the data myself?

meow13:01:21

me three

dnolen14:01:24

@lfn3: don’t really have anything more to add than what I said

denik15:01:31

re: Links is it possible to pass an actual query instead of [:current-user _]? I have a current-user that has a bunch of posts that have been normalized so I get

{:current-user {:user/posts [[:post/by-id 1] [:post/by-id 2]]}}

denik15:01:50

Since there is no query my read :current-user fn does not get the posts

dnolen15:01:47

@denik: {[:currrent-user _] …} should work yes, bug if it doesn't

denik15:01:29

@dnolen: next.cljs:1195 Uncaught RangeError: Maximum call stack size exceeded

dnolen15:01:53

@denik error messages alone aren’t useful information to me

dnolen15:01:06

make a minimal case and file an issue

dnolen16:01:37

@denik the minimal example is hard to understand

dnolen16:01:58

don’t use ’… unless you actually mean the recursion symbol

dnolen16:01:57

@denik right my fault

denik16:01:02

let me fix

denik16:01:04

same issue

dnolen16:01:09

supply whatever you actually mean to use there

denik16:01:29

to [:user/posts]

anmonteiro16:01:32

@dnolen: @denik FWIW works on latest master

denik16:01:47

@dnolen okay error goes away but query results are the same

dnolen16:01:59

@denik: right you should be using master too

dnolen16:01:07

reporting errors about the alphas is not helpful

denik16:01:19

okay will do

denik16:01:58

@anmonteiro: are you getting denormalized values, in this case the user posts?

denik16:01:45

hmm isn’t that what db-tree should get?

anmonteiro16:01:58

@denik: let me have a look again

denik16:01:48

@anmonteiro: nevermind didn’t pass join query-segment

anmonteiro16:01:24

what do you mean by that?

denik16:01:32

@anmonteiro: had to pass (parser {:state reconciler} '[{[:current-user _] [{:user/posts [:post/name]}]}])

anmonteiro16:01:51

I wasn't seeing that

anmonteiro16:01:39

it should work

denik16:01:10

@anmonteiro: well it looks like it does not

anmonteiro16:01:33

@denik: neither does the one with the join-segment

anmonteiro16:01:36

for me at least

denik16:01:44

hmm, you have all the info I got. Using om master and it pasted the above from my repl.