Created
July 20, 2015 12:17
-
-
Save dark4eg/7cec65e102152688d6fb 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
(defmulti build | |
"Component build" | |
(fn [cursor owner opts] | |
(-> cursor :component :type))) | |
(defmethod build [:button] [cursor owner opts] | |
(reify | |
event-bus/IInitEventBus | |
(init-event-bus [_] | |
{:xform (add-om-id-xform owner)}) | |
om/IWillMount | |
(will-mount [_]) | |
om/IDidMount | |
(did-mount [_]) | |
om/IWillReceiveProps | |
(will-receive-props [_ next-props]) | |
om/IWillUnmount | |
(will-unmount [_]) | |
om/IWillUpdate | |
(will-update [_ next-props next-state]) | |
om/IDidUpdate | |
(did-update [_ prev-props prev-state]) | |
om/IRenderState | |
(render-state [_ state] | |
(html/render (if (> (count (:view (:component cursor))) 0) | |
(:view (:component cursor)) | |
[:button {:type "button" | |
:class "btn"} | |
"button"]))))) | |
(def app-state (atom {:button {:type [:button] | |
:view [:button {:type "button" | |
:class "btn btn-default mdi-navigation-menu" | |
:on-click (fn [c] | |
(println "owner" owner))}]}})) | |
(om/root | |
(fn [cursor owner] | |
(om/build builder/build {:component (:button cursor})) | |
app-state | |
{:target (. js/document (getElementById "app")) | |
;:chsk-send! chsk-send! | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment