-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
The current examples show how to create Om components that depend on the global app state but it is not clear how to create one that uses a local component state. Having an example would be therefore nice.
This is what I do, though I am not sure it is the best way - essentially wrapping a snippet in a stateful component:
(defsnippet search-html "index.html"
[:#search]
[{:keys [value]} owner]
{[:#search-input] (kioo/do->
(kioo/set-attr :value value)
(kioo/set-attr :onChange #(handle-search % owner)))})
(defn search-input
"Stateful wrapper around the search Kioo template"
[app owner]
(reify
om/IInitState
(init-state [_] {:value nil})
om/IRenderState
(render-state [this state] (search-html state owner))))
;;;; Somewhere later, when attaching to a root:
;; (om/build search-input (om/graft {} app))Thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels