Liking cljdoc? Tell your friends :D

License: MIT

re-frame-form

Library to privide some common functionality for forms in re-frame.

Api

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]])

Event handlers

:imatic.re-frame.form.events/init-form

Initializes form with data.

usage:

(dispatch [::ievents/init-form {:id :form-id, :initial-data {:email ""}])

:imatic.re-frame.form.events/clear-form

Removes form from app-db.

usage:

(dispatch [::ievents/clear-form :form-id])

:imatic.re-frame.form.events/clear-field

Removes field from the form.

usage:

(dispatch [::ievents/clear-field :form-id :email])

:imatic.re-frame.form.events/update-field

Updates field value.

usage:

(dispatch [::ievents/update-field :form-id :email "user@example.com"])

:imatic.re-frame.form.events/update-errors

Sets errors to the form.

usage:

(dispatch [::ievents/update-errors :form-id {:email "This value is not valid email"}])

Subscribers

:imatic.re-frame.form.subs/form

Retrieves all data for given form.

usage:

(subscribe [::isubs/form :form-id])

:imatic.re-frame.form.subs/field-error

Retrieves errors for given field.

usage:

(subscribe [::isubs/field-error :form-id :email])

:imatic.re-frame.form.subs/field-value

Retrieves value of given field.

usage:

(subscribe [::isubs/field-value :form-id :email])

:imatic.re-frame.form.subs/field-values

Retrieves values for all fields.

usage:

(subscribe [::isubs/field-values :form-id])

:imatic.re-frame.form.subs/initialized?

Returns true if form is initialized, false otherwise.

usage:

(subscribe [::isubs/field-values :form-id])

Queries

imatic.re-frame.form.queries/field-values

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