Fork me on GitHub
#om-next
<
2016-09-05
>
hlolli12:09:51

If you are asking about passing properties, which Im not sure since its not in your code. Then pass properies to it (maybe from root) by (dialog-modal {:dialog/id id}) given that id is a property/value coming from its parent component. Dont know well om/get-computed, never found a reason to use it.

levitanong18:09:22

@am-a_metail I can’t imagine that maintaining a separate globally scoped map of values would be more idiomatic than what you did in the beginning. What your colleague suggests seems rather contrived to me. Further, if he suggests that route, why not place the contents of error-data in app state altogether? In which case, you’d have a separate (defui Error) containing an (ident [this {:keys [dialog/id]}] [:error/by-id id]) and (query [this] [:error/title :error/message]). Ad then your Dialog would include the Error’s query and incorporate it into its own.

levitanong18:09:47

I’m assuming you intend Dialog to be as general as possible—which would mean that it shouldn’t know anything about your app state’s structure. It seems to me that om/computed is the correct way to go.

am-a_metail18:09:53

Thanks @levitanong - that was my intention

am-a_metail18:09:19

And the ident never occurred to me but makes perfect sense

levitanong18:09:35

You get other benefits in going om/computed as well. You can pass other hiccup syntax like (dialog-modal (om/computed {} {:message [:div [:div [:div [:div “derp”]]]]}))

am-a_metail18:09:23

Is that better than using children?

levitanong18:09:59

even better:

(dialog-modal (om/computed {}
  {:message [:div “close me” 
               [:button {:on-click some-close-fn} “Close”]]})

am-a_metail18:09:27

Yeah I like that

levitanong18:09:40

what is better than using children?

am-a_metail18:09:13

See first example: (om/children) for example

am-a_metail18:09:30

(dialog-modal (om/computed ...) (child/view {})

levitanong18:09:41

Oh, well I didn’t know about om/children at all 😛 I don’t think that’s documented at all!

levitanong18:09:45

Now I feel silly

levitanong18:09:57

Today I learned.

am-a_metail18:09:29

Not silly - it's not documented as you say

levitanong18:09:53

I would still maintain my stance though, that if your component is to be generic, it shouldn’t know the structure of your app. Like, you should be able to drop it into another app.

levitanong18:09:02

and it should work just fine.

levitanong18:09:10

So I think you’re doing the right thing 🙂

am-a_metail18:09:38

I am constantly fighting YAGNI even when the effort for reusability is equal/less

am-a_metail18:09:58

And now spend half my time fixing bugs

am-a_metail18:09:24

But thanks for confirming I wasn't doing something weird

am-a_metail18:09:29

Or too weird anyway

levitanong18:09:27

No problem 🙂 Thanks for letting me know about om/children! 🍻