Hello all,

I'd like to improve on a simple pattern for reusable modals in Om. The example 
code linked below at [1] works, displaying a person details modal as expected. 
However, it has some downsides. Specifically, the "person-details-modal" 
component must be given the state of the higher-level component that creates 
it, and it must know the key in which its state exists so it can update it.

We can work around this if we pass "on close" callbacks to the modal component, 
and remove its state in the parent. But that leaks details in the opposite 
direction, where the caller of a modal has to know how to close it.

Can we make this code cleaner? Realizing this could be a challenge in the 
context of Om's strong state management, it would be nice to write something 
like this:

(defn show-person-details-modal! [person-details] ...)

that could be attached to the on-click event of a parent component. It's not 
clear to me how we could achieve that, or if it's possible. Any other 
suggestions to work around the above drawbacks are also welcome. I'd love to 
see how this is handled in existing Om-based projects.

If anyone wants to experiment with this example, simply cloning the project 
below and launching "lein run" will open a page with this example.

Many thanks!

-Ryan

[1]
https://github.com/rbrush/cljs-playground/blob/master/src/main/clojurescript/toomuchcode/playground/modal.cljs

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to