om

Please ask the channel first, not @dnolen directly!
wilkerlucio 2017-07-03T12:34:35.322003Z

hello people, I would like to announce a new little open-source project I built with Om.next + Untangled, it's a Chrome extension to represent an Youtube Queue based your emails, I made a post about it, I hope you can enjoy it 🙂 https://medium.com/@wilkerlucio/using-gmail-messages-to-track-youtube-channels-ef35308a0ceb

👍 5
samcf 2017-07-03T16:41:42.726430Z

Something I don't see in om.next projects are deeply nested component hierarchies... where the leafs have unpredictable data needs. Are there any examples of that?

wilkerlucio 2017-07-03T16:59:29.092014Z

@samcf what you mean by unpredictable data needs?

samcf 2017-07-03T17:03:10.173170Z

@wilkerlucio ex. Component A has child Component B which has child Component C, and some feature requirement changes where C needs some data it hadn't anticipated... how do I change C's query to get some data that is at the root of the state map?

sundarj 2017-07-03T17:03:52.187899Z

https://github.com/omcljs/om/wiki/Thinking-With-Links%21 does this explain what you mean?

peeja 2017-07-03T17:04:05.192551Z

@samcf You're talking about at dev time, not at run time?

samcf 2017-07-03T17:04:42.205937Z

@peeja Right, trying to change C's query in a way that doesn't necessitate changing A and B

samcf 2017-07-03T17:05:03.213325Z

@sundarj I've read it a few times... maybe I haven't grokked it

sundarj 2017-07-03T17:05:36.225541Z

the way i see it is, it lets you get an item out of the root state without having to go through all the parent components beforehand

sundarj 2017-07-03T17:05:43.228167Z

which seems to be what you're asking for

peeja 2017-07-03T17:06:01.234298Z

My gut reaction is that your component hierarchy or your graph may be flawed. You can get back to the root using a singleton link from anywhere, but it's often (in my experience) a smell

peeja 2017-07-03T17:06:37.247080Z

If component C represents "a C" in your domain model, why would it need props which don't belong to the C it's representing?

sundarj 2017-07-03T17:07:09.257843Z

so if C needs access to :key in the state, you can get at it by plonking [:key _] into the query

samcf 2017-07-03T17:09:13.298545Z

@sundarj hmm I will try that! If that works then that's exactly what I needed. @peeja for example, in toy app, https://github.com/samcf/sojourner/blob/master/src/sojourner/ui.cljs#L43 this component needs some data (the current time in milliseconds) that doesn't necessarily "belong" to the component.

peeja 2017-07-03T17:09:52.311823Z

Ah, I'd call that a mistake: the current time shouldn't be a prop

peeja 2017-07-03T17:10:00.314355Z

Or rather, it shouldn't be part of your data model

peeja 2017-07-03T17:10:41.327569Z

The source of truth for the current time shouldn't be your "database", it should be the clock on the wall

samcf 2017-07-03T17:10:49.330277Z

the current time is part of the model, since the app is a simulation which may run at different speeds, etc...

peeja 2017-07-03T17:11:00.333866Z

Oh! Gotcha. That's different, then. 🙂

peeja 2017-07-03T17:12:41.365591Z

In this case, I might pass the current time to the Game as a computed prop

peeja 2017-07-03T17:13:10.374578Z

That is, you're asking the Game component to render a game (with all the data it needs about a game) as if the current time were X

peeja 2017-07-03T17:13:32.381889Z

and it's the RootView's responsibility to decide on the X by querying for it in the app state

samcf 2017-07-03T17:14:33.401764Z

Now let's imagine Game is 10 components deep into the UI tree... either I have to fix my component tree or pass it all the way down (or use [:current-time _] as suggested)

peeja 2017-07-03T17:14:39.403753Z

Using a singleton ident to jump back to the root of the graph to look it up works too, but using a computed prop would keep the component a bit more modular, as it wouldn't have to know about the structure of the graph at the root

💡 1
peeja 2017-07-03T17:15:18.416293Z

Yep, that's correct. It's a tradeoff, and I think either way is defensible. It depends on context.

peeja 2017-07-03T17:15:32.420789Z

and the reasoning's a bit fuzzy either way 🙂

samcf 2017-07-03T17:15:41.423625Z

👍 this has been informative

peeja 2017-07-03T17:16:05.430924Z

BTW, it looks like RootView is using query params which don't actually change. Is that right?

samcf 2017-07-03T17:16:38.441519Z

yeah that's right, it just looked neat when I had it that way, but its unnecessary

samcf 2017-07-03T17:17:00.448717Z

still learning/toying around

peeja 2017-07-03T17:17:01.448919Z

Cool. Just wanted to make sure you knew it wasn't necessary