-
-
Save eyston/df7da936b0bb078620d4 to your computer and use it in GitHub Desktop.
This file contains 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
(ns om-tutorial.indexer | |
(:require [goog.dom :as gdom] | |
[om.next :as om :refer-macros [defui]] | |
[om.dom :as dom])) | |
(enable-console-print!) | |
(defmulti read om/dispatch) | |
(defmethod read :sections | |
[{:keys [query state]} k _] | |
(let [st @state] | |
{:value (om/db->tree query (get st k) st)})) | |
(defui SectionOne | |
static om/IQuery | |
(query [_] | |
[:name]) | |
Object | |
(render [this] | |
(dom/div nil (-> this om/props :name)))) | |
(def section-one (om/factory SectionOne)) | |
(defui RootRoute | |
static om/IQuery | |
(query [_] | |
[{:sections [{:section-one (om/get-query SectionOne)}]}]) | |
Object | |
(render [this] | |
(dom/div nil | |
"Main" | |
(section-one (-> this om/props :sections :section-one))))) | |
(def reconciler | |
(om/reconciler | |
{:state {:sections {:section-one {:name "Section One"}}} | |
:parser (om/parser {:read read})})) | |
(om/add-root! reconciler RootRoute (gdom/getElement "app")) | |
(let [class-paths (-> @(om/get-indexer reconciler) :class-path->query keys)] | |
; alpha-28: ([om-tutorial.indexer/RootRoute] [om-tutorial.indexer/RootRoute om-tutorial.indexer/SectionOne]) | |
; alpha-30: ([om-tutorial.indexer/RootRoute] [om-tutorial.indexer/RootRoute om-tutorial.indexer/SectionOne]) | |
; alpha-31-snapshot: ([om-tutorial.indexer/RootRoute]) | |
(println "class-paths" class-paths)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment