# om

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

levitanong 01:56:55

@anmonteiro I have a query question:

Say I have an app that has several levels of list views and detail views. The detail views show more information about a selected item on the list.

Right now, since I have several list-detail pairs at varying levels of depth in the app, I’ve opted for using links to store information on the selected states of these lists, and the app just gets the linked information in their queries to display the details.

Ideally, the list-item (let’s call them stubs) views should have smaller queries, and shouldn’t even reference anything beyond the name. I mean, if you have a list of school-stubs, the school-stubs shouldn’t list the classroom entities in the queries, right? It should just be the school-detail that contains the queries asking for classrooms (which in turn have classroom-stubs and classroom-details, the details of which should only have queries for student entities)

The problem is, when I go about it that way, the normalization fails. The normalization seems to only expect looking at the school-stubs, and seeing that there are no references to classrooms, stop at the school level. The links are ignored.

So if I want proper normalization, I have to include all the references in the stub level. Problem with this is, the queries become unnecessarily large, and incur a performance penalty.

Now I’m trying to think of a way out of this.
1. The most direct route it seems (though the most tedious) is to manually normalize everything the way I want it to, so that I can structure the queries to be properly lean.
2. I could make a separate query at the root specifically only to normalize, and be lean everywhere else. This would make initial load long, but if I don’t ask for that query again, it won’t happen again, and things stay lean. (Not sure if there are any gotchas here though, as I have yet to try it. I worry there might be some query complaints for duplicate stuff.)
3. If the structure of the app were flatter, I figure people would most likely suggest using IQueryParams. Is having a query like the below going to work like I want it to? Will it result in the same problem as with links? Somehow I feel as if this will be problematic anyway.
[{:system/schools [:school/id :school/name] ({:system/selected-school (om/get-query School)} {:school-id ?school-id})]

So I’d appreciate your thoughts on the matter :smile:

levitanong 02:33:14

Hmmm… I realize I could use tree->db to pre-normalize the data.

danielstockton 10:42:17

Is anyone handling file uploads in an app? Interested in hearing your strategies.

danielstockton 11:26:36

@danielstockton uploaded a file: Untitled

danielstockton 11:27:55

This is what my send function is starting to look like. I split the query into two separate requests so I can send uploads as multipart. @drcode @dzannotti I think this has similarities to how you are dealing with REST endpoints.

stuartsierra 20:36:40

Is it reasonable to use just defui and other rendering-related functionality from without the rest of it?

anmonteiro 20:37:27

@stuartsierra I've done that myself in projects that didn't use queries

stuartsierra 20:44:32

OK, thanks.

stuartsierra 21:43:29

If I'm just rendering, do I have to use the reconciler?

anmonteiro 22:22:26

@stuartsierra: depends. If you have global state you'll need to construct a reconciler with it

anmonteiro 22:24:02

Well, in fact you could make do with passing just props to a Om Next factory, but your components wouldn't re-render. You'd need to set up a watch on an atom to re-render manually

solussd 22:43:07

What’s the best approach to consuming NPM packages for my clojurescript app? lein-npm? webpack (idk how this works)? npm is a tire-tire afaict.

solussd 22:43:49

also, I don’t suppose there’s a way to rope npm deps into a clojurescript closure compiler advanced compile.

stuartsierra 23:06:45

OK thanks anmonteiro

anmonteiro 23:09:51

@solussd use Webpack to create a UMD module that you include via :foreign-libs compiler option

solussd 23:10:31

@anmonteiro cool- any example projects/blog posts you’d recommend?

solussd 23:10:45

I should probably figure out this webpack thing, regardless. :slightly_smiling_face:

anmonteiro 23:11:54

I think I found that whole mailing list thread useful