Last active
November 26, 2015 11:14
-
-
Save ThomasDeutsch/36b080f41ad52605b864 to your computer and use it in GitHub Desktop.
why is the reader called twice, after the query params get modified?
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 read om/dispatch) | |
(defmethod read :input-handler | |
[{:keys [query state]} k {:keys [query]}] | |
(println "read: input-handler") | |
(let [st @state] | |
{:value {:input-handler (clojure.string/join [query "+X"]) }})) | |
(defui SomeInput | |
static om/IQueryParams | |
(params [_] | |
{:str ""}) | |
static om/IQuery | |
(query [_] | |
'[(:input-handler {:str ?str})]) | |
Object | |
(render [this] | |
(dom/input | |
#js {:key "search-field" | |
:value (:str (om/get-params this)) | |
:onKeyUp | |
(fn [e] | |
(om/set-query! this | |
{:params {:str (.. e -target -value)}}))}))) | |
(def reconciler | |
(om/reconciler | |
{:state init-data | |
:parser (om/parser {:read read})})) | |
(om/add-root! reconciler SomeInput (gdom/getElement "app")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment