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.
@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.
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.
Thanks @levitanong - that was my intention
And the ident never occurred to me but makes perfect sense
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”]]]]}))
Is that better than using children?
even better:
(dialog-modal (om/computed {}
{:message [:div “close me”
[:button {:on-click some-close-fn} “Close”]]})
Yeah I like that
what is better than using children?
See first example: (om/children) for example
(dialog-modal (om/computed ...) (child/view {})
Or something
Oh, well I didn’t know about om/children at all 😛 I don’t think that’s documented at all!
Now I feel silly
Today I learned.
Not silly - it's not documented as you say
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.
and it should work just fine.
So I think you’re doing the right thing 🙂
I am constantly fighting YAGNI even when the effort for reusability is equal/less
And now spend half my time fixing bugs
Bah
But thanks for confirming I wasn't doing something weird
Or too weird anyway
No problem 🙂 Thanks for letting me know about om/children
! 🍻