Skip to content

Instantly share code, notes, and snippets.

@alexhemard
Last active October 23, 2015 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexhemard/21b6b0f369dfababb6f7 to your computer and use it in GitHub Desktop.
Save alexhemard/21b6b0f369dfababb6f7 to your computer and use it in GitHub Desktop.
(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