Last active
February 8, 2017 04:40
-
-
Save caryfitzhugh/bf533b53f15de00133500d9961209826 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
{ | |
;; Data is the subscriptions (in reflux / re-frame) | |
;; Data flows from subscription to subscription | |
;; Some data is sourced by an API path (and is requested automatically if needed) | |
;; Other data is derived from other subscriptions (:sources, etc) | |
:data { | |
:all-tenants { | |
:api-path “/v1/tenants” ;; This would be a source / root | |
:key :tenants/all-tenants ;; Others could use this. And the data is stored in this key | |
} | |
:tenant-names { | |
;; Views should be mostly logicless, so these reductions will convert things | |
:sources [:all-tenants] | |
:reduce (fn [all-tenants] (:name tenant)) | |
} | |
} | |
:events { | |
:save-tenant { | |
:ajax { | |
:path "/v1/tenants/:drn" ;; Automatically pull parameters out of the incoming data (:drn) | |
:update ( ) ;; How do you update the local store with your data? ;; TBD? | |
} | |
} | |
:routes { | |
:/tenants/ { | |
:navigation "Tenants" | |
:subnavs { | |
"Name of link (or html)" :/route/to/go/to | |
} | |
:template [:div | |
"just a regular hiccup template" | |
;; Iterate over each data element. it's param is name - and then a hiccup template. | |
(each (data :tenant-names) [name] [:div name ]) | |
;; Emit an event to :save-tenant | |
[:a :on-click (evt :save-tenant) "Save Tenant"] | |
] | |
} | |
:/tenants/:tenant-drn { | |
:template [:div | |
;; Pull a parameter in here from the path | |
[:header (param :tenant-drn) | |
] | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment