created a typeahead. neat.

This commit is contained in:
Bryce Covert
2018-05-23 00:30:04 -07:00
parent 37371024d1
commit 1a72859bd8
5 changed files with 138 additions and 20 deletions

View File

@@ -68,11 +68,22 @@
keys (dissoc keys :field :subscription :event :spec)]
(into [dom keys] (with-keys rest))))
(defmethod do-bind "typeahead" [dom {:keys [field event subscription class spec] :as keys} & rest]
(let [field (if (keyword? field) [field] field)
event (if (keyword? event) [event] event)
keys (assoc keys
:on-change (fn [selected]
(re-frame/dispatch (conj (conj event field) selected)))
:value (get-in subscription field)
:class (str class
(when (and spec (not (s/valid? spec (get-in subscription field))))
" is-danger")))
keys (dissoc keys :field :subscription :event :spec)]
(into [dom keys] (with-keys rest))))
(defmethod do-bind :default [dom {:keys [field event subscription class spec] :as keys} & rest]
(let [field (if (keyword? field) [field] field)
event (if (keyword? event) [event] event)
_ (println field event dom rest)
keys (assoc keys
:on-change (dispatch-value-change (conj event field))
:value (get-in subscription field)