Skip to content

Instantly share code, notes, and snippets.

@eyston
Last active January 27, 2016 23:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save eyston/057953716bb2dff7c0ef to your computer and use it in GitHub Desktop.
(defmethod mutate 'form-submit
[{:keys [state]} _ _]
{:action (fn []
(swap! state
(fn [st]
(if-let [errors (validate state)]
(assoc st :errors errors)
(assoc st :state :valid)))))
:remote (= :valid (:state @st))})
;; or ...
(defn form-submit [form-state]
(if-let [errors (validate form-state)]
(om/transact! this '[(form-errors {:errors errors})])
(om/transact! this '[(do-action {:params (calculate-params form-state)})])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment