Skip to content

Instantly share code, notes, and snippets.

@caryfitzhugh
Last active February 8, 2017 04:40
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 caryfitzhugh/bf533b53f15de00133500d9961209826 to your computer and use it in GitHub Desktop.
Save caryfitzhugh/bf533b53f15de00133500d9961209826 to your computer and use it in GitHub Desktop.
{
;; 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