Library to privide some common functionality for forms in re-frame.
This section assumes that code is written in file with following requires:
(:require
[re-frame.core :refer [dispatch subscribe]]
[imatic.re-frame.form.events :as ievents]
[imatic.re-frame.form.subs :as isubs]
[imatic.re-frame.form.queries/field-values :refer [field-values]])
Initializes form with data.
usage:
(dispatch [::ievents/init-form {:id :form-id, :initial-data {:email ""}])
Removes form from app-db
.
usage:
(dispatch [::ievents/clear-form :form-id])
Removes field from the form.
usage:
(dispatch [::ievents/clear-field :form-id :email])
Updates field value.
usage:
(dispatch [::ievents/update-field :form-id :email "user@example.com"])
Sets errors to the form.
usage:
(dispatch [::ievents/update-errors :form-id {:email "This value is not valid email"}])
Retrieves all data for given form.
usage:
(subscribe [::isubs/form :form-id])
Retrieves errors for given field.
usage:
(subscribe [::isubs/field-error :form-id :email])
Retrieves value of given field.
usage:
(subscribe [::isubs/field-value :form-id :email])
Retrieves values for all fields.
usage:
(subscribe [::isubs/field-values :form-id])
Returns true
if form is initialized, false
otherwise.
usage:
(subscribe [::isubs/field-values :form-id])
Retrieves values of the form from app-db
.
usage:
(field-values db :form-id)
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close