There's no imperative to structure your data in a hierarchical manner
like this. If you find it unsuitable for your application change the
representation. Also ref cursors were designed specifically to support
putting up an API in front of the data so that the data representation
can evolve independently of components that rely on aspects of the
data.

David

On Fri, Oct 31, 2014 at 4:09 PM, Andreas Liljeqvist <[email protected]> wrote:
> Hi.
>
> For example I have this hierarchy:
>
>
> Guest
> Room
> Hotel            Guest-settings
>            Root
>
> (defn ui-state []
>   (om/ref-cursor (:ui-state (om/root-cursor app-state))))
>
>
> (def app-state atom({:ui-state {:selected nil}
>                      :hotels [{:name "stay4free"
>                                :rooms [{:id 202 :guests
>                                         [{:id 123 :name "Poor slob"}]}]}]}))
>
> I can selected a guest by clicking on a guest node.
> That will trigger an update! that changes a reference cursor [:ui-state
> :selected] to the guest id.
>
> Whenever that happens I want to display some textboxes and sliders to change
> information about the guest.
>
> Problem is that I don't have a handy reference to the guest, only an unique
> id.
> Since guest-settings is going to do something like (om/build guest-settings
> (:ui-state app))
>
> I can use the id in :selected to dig down through the hierarchies until I
> find the right guest.
> Seems like a sub-optimal solution though.
>
> Any tips?
> Thanks.
>
> --
> 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.

-- 
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