Created
March 29, 2016 02:58
-
-
Save anonymous/096d229ecd7237f2a547 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
(def search-term (atom "")) | |
(defn input [model on-change] | |
(let [external-model (atom @model) | |
internal-model (atom (or @external-model ""))] | |
(fn [model on-change] | |
;; this is taken from recom - http://bit.ly/1SZ1OXn | |
(when (not= @external-model @model) | |
(.log js/console "changed to " @model) | |
(reset! external-model @model) | |
(reset! internal-model @model)) | |
[:input.form-control | |
{:value @internal-model | |
:on-change (fn [e] | |
(let [v (.-value (.-target e))] | |
(reset! internal-model v) | |
(on-change @internal-model)))}]))) | |
[:div | |
[input search-term (fn [v] (reset! search-term v))] | |
[:button {:on-click #(reset! search-term "")} "Reset"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment