Fork me on GitHub
#om
<
2017-03-21
>
danielstockton11:03:14

I have the following component hierarchy: Wrapper -> Header -> Nav -> [Dropdown1, Dropdown2, Dropdown3] Dropdown1, Dropdown2, Dropdown3 can change based on route (effectively I want a secondary routing system alongside compassus for main routing). I want to be able to add root queries to Dropdown1, Dropdown2...How would you do this?

jannis11:03:04

Global links? {[:foo _] <subquery>}

danielstockton11:03:38

@jannis What would the query look like in Wrapper, Header, Nav? I was thinking it would involve some recursive parsing like in https://awkay.github.io/om-tutorial/#!/om_tutorial.E_State_Reads_and_Parsing

danielstockton11:03:37

Do you always need to hike the child query into the parent or can you have a query with a link just floating in space?

jannis11:03:01

Ah, no, I’m almost sure you can’t.

jannis11:03:10

What I’m doing these days is recursive parsing with a single read entry point, using my own query engine and data store. You can lose some of Om Next’s features that way though.

danielstockton11:03:13

I think it will work with something like this:

(defmethod read :header
  [{:keys [query parser] :as env} _ _]
  {:value (parser env query)})

(defmethod read :nav
  [{:keys [query parser] :as env} _ _]
  {:value (parser env query)})
for all the intermediary components..

danielstockton11:03:32

It just nests it under the key and delegates the query to the next level.

jannis11:03:43

That by itself doesn’t solve the problem but I never liked the idea to use join keys that are tied to the UI just to pull in sub-component queries. So I decided to never do that and always only join on actual data / entities.

danielstockton11:03:43

Yeah, I don't like it either but I can't see another way other than inventing my own query engine, as you say...

danielstockton12:03:19

I wrote

(defmethod read :delegate/nav
  [{:keys [query parser] :as env} _ _]
  {:value (parser env query)})
and I just use this key in all components that I want to just pass props through... Not sure if this is a good idea or not but it works.

rgm17:03:43

hi all, super newb here... can anyone give me pointers to any overviews on why I'd pick either om.dom or sablono? I presume there's a reason they both exist, and I'm guessing there's some extra stuff that om.dom is doing.

anmonteiro17:03:46

@rgm choose what you prefer. the only thing to be aware of is that sablono won’t support server-side rendering if you eventually want to go through that path

rgm17:03:09

ah, ok. That is a good thing to know, thx.

rgm17:03:34

seems like they mix/match/compose, so if I were feeling particularly hostile to future-me I could om.dom only the parts that I currently guess would benefit from SSR.

rgm17:03:29

seems to be pre-om.next but I guess this'd be another pro of om.dom ... http://swannodette.github.io/2014/02/27/taking-off-the-blindfold

petterik18:03:48

Changing file extensions from .cljs to .cljc and seeing my UI loading instantly with SSR was extremely satisfying

baptiste-from-paris20:03:51

hello guys, any recommandation for validation in forms ? I am not talking about the validator key in factory which assert props (and then throw an error if it goes wrong). I am more talking of a strategy to validate user’s input

baptiste-from-paris20:03:59

Do you use simple components ?