Fork me on GitHub
#om
<
2016-11-14
>
dnolen19:11:29

@anmonteiro OM-799 needs a rebase

dspiteself20:11:25

@anmonteiro cool work on the js-modules branch I have been wondering how that would work

tobiash21:11:59

I'd like to subscribe an Om component to a core.async channel while it is mounted. Being new to both libraries, does that mean that I should create a "cancel"-channel in the component, so that I can stop the go-loop on unmount? Like (alts! [input cancel])? Or is there a simpler alternative?

denik22:11:24

I’m playing around with multiple components that take the same data but index it with different idents. I end up having duplicate data in the app db. Mainly because Om can’t know that a link should point to another, and which link should point be pointing in the first place. Any ideas?

(let [st          {:app/users        [{:id        1
                                           :user/name "Eva"
                                           :user/type :type/foo}
                                          {:id        2
                                           :user/name "Fred"
                                           :user/type :type/foo}
                                          {:id        3
                                           :user/name "Elli"
                                           :user/type :type/bar}]
                       :app/current-user {:id 1}}
          User        (ui
                        static om/Ident
                        (ident [_ {:keys [id]}]
                               [:user/by-id id])
                        static om/IQuery
                        (query [_]
                               [:id
                                :user/name
                                :user/type]))
          UnionFooBar (ui
                        static om/Ident
                        (ident [_ {:keys [user/type id]}]
                               [type id])
                        static om/IQuery
                        (query [_]
                               {:type/foo (om/get-query User)
                                :type/bar (om/get-query User)
                                }))]

      (pprint
        (om/tree->db [{:app/users (om/get-query UnionFooBar)}
                      {:app/current-user (om/get-query User)}] st true))

      {:app/users        [[:type/foo 1] [:type/foo 2] [:type/bar 3]],
       :app/current-user [:user/by-id 1],
       :type/foo
                         {1 {:id 1, :user/name "Eva", :user/type :type/foo},
                          2 {:id 2, :user/name "Fred", :user/type :type/foo}},
       :type/bar         {3 {:id 3, :user/name "Elli", :user/type :type/bar}},
       :user/by-id       {1 {:id 1, :user/name "Eva", :user/type :type/foo}},
       :om.next/tables   #{:type/foo :type/bar :user/by-id}})