Last active
October 23, 2015 18:59
-
-
Save alexhemard/21b6b0f369dfababb6f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def init-data | |
{:universe | |
{:size js/Infinity | |
:beings [{:name "John"} | |
{:name "Mary"}]}}) | |
(defui Being | |
static om/Ident | |
(ident [this {:keys [name]}] | |
[:being/by-name name]) | |
static om/IQuery | |
(query [this] | |
'[:name])) | |
(defui Universe | |
static om/IQuery | |
(query [this] | |
(let [being (om/get-query Being)] | |
`[:size {:beings ~being} ]))) | |
(defui RootView | |
static om/IQuery | |
(query [this] | |
(let [universe (om/get-query Universe)] | |
`[{:universe ~universe}]))) | |
(def norm-data (om/normalize RootView init-data true)) | |
(def expected | |
{:universe {:size js/Infinity | |
:beings [[:being/by-name "John"] | |
[:being/by-name "Mary"]]} | |
:being/by-name {"John" {:name "John"} | |
"Mary" {:name "Mary"}}}) | |
(.log js/console norm-data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment