Liking cljdoc? Tell your friends :D

reagent-utils

This library provides a number of convenience helpers for use with Reagent.

Clojars Project

reagent.cookies

clear!

(clear!)
removes all cookies

contains-key?

(contains-key? k)
is the key present in the cookies

contains-val?

(contains-val? v)
is the value present in the cookies (as string)

count

(count)
returns the number of cookies

empty?

(empty?)
true if no cookies are set

get

(get k & [default])
gets the value at the key (as edn), optional default when value is not found

get-raw

(get-raw k & [default])
gets the value at the key (as string), optional default when value is not found

keys

(keys)
returns all the keys for the cookies

raw-vals

(raw-vals)
returns cookie values (as strings)

remove!

(remove! k)(remove! k path domain)
removes a cookie, optionally for a specific path and/or domain

set!

(set! k content & [{:keys [max-age path domain secure? raw?]} :as opts])
sets a cookie, the max-age for session cookie
following optional parameters may be passed in as a map:
:max-age - defaults to -1
:path - path of the cookie, defaults to the full request path
:domain - domain of the cookie, when null the browser will use the full request host name
:secure? - boolean specifying whether the cookie should only be sent over a secure channel
:raw? - boolean specifying whether content should be stored raw, or as EDN

vals

(vals)
returns cookie values (as edn)

reagent.crypt

bytes->hex

(bytes->hex bytes-in)
convert bytes to hex

digest

(digest hasher bytes)

hash

(hash s hash-type & [hex?])

hash-bytes

(hash-bytes s hash-type)

string->bytes

(string->bytes s)

reagent.format

add-slashes

(add-slashes s)

capitalize-words

(capitalize-words s)

center

(center text w)

currency-format

(currency-format n)
formats currency using the current locale
to change locale set goog.i18n.NumberFormatSymbols eg:
(set! goog.i18n.NumberFormatSymbols goog.i18n.NumberFormatSymbols_it_IT)
see here for supported locales
https://github.com/google/closure-library/blob/master/closure/goog/i18n/compactnumberformatsymbols.js

date-format

(date-format date fmt & [tz])

encode-uri

(encode-uri uri)

format

(format fmt & args)
Formats a string using goog.string.format.
e.g: (format "Cost: %.2f" 10.0234)

line-numbers

(line-numbers s)

pluralize

(pluralize items & [word ending1 ending2 :as opts])
pluralizes the word based on the number of items
(util/pluralize ["John"] "lad")
(util/pluralize ["John" "James"] "lad")
(util/pluralize ["Alice"] "lad" "y" "ies")

printf

(printf fmt & args)
Prints formatted output, as per format

remove-tags

(remove-tags s & tags)
removes specified tags, eg:
(remove-tags "<p>foo bar</p>" "p")

reagent.session

assoc-in!

(assoc-in! ks v)
Associates a value in the session, where ks is a
sequence of keys and v is the new value and returns
a new nested structure. If any levels do not exist,
hash-maps will be created.

clear!

(clear!)
Remove all data from the session and start over cleanly.

get

(get k & [default])
Get the key's value from the session, returns nil if it doesn't exist.

get!

(get! k & [default])
Destructive get from the session. This returns the current value of the key
and then removes it from the session.

get-in

(get-in ks & [default])
Gets the value at the path specified by the vector ks from the session,
returns nil if it doesn't exist.

get-in!

(get-in! ks & [default])
Destructive get from the session. This returns the current value of the path
specified by the vector ks and then removes it from the session.

put!

(put! k v)

remove!

(remove! k)
Remove a key from the session

reset!

(reset! m)

state

swap!

(swap! f & args)
Replace the current session's value with the result of executing f with
the current value and args.

update!

(update! k f & args)
Updates a value in session where k is a key and f
is the function that takes the old value along with any
supplied args and return the new value. If key is not
present it will be added.

update-in!

(update-in! ks f & args)
Updates a value in the session, where ks is a
sequence of keys and f is a function that will
take the old value along with any supplied args and return
the new value. If any levels do not exist, hash-maps
will be created.

reagent.validation

Functions for validating input and setting string errors on fields.

equal-to?

(equal-to? v n)
Returns true if the string represents a number = given.

greater-than?

(greater-than? v n)
Returns true if the string represents a number > given.

has-value?

(has-value? v)
Returns true if v is truthy and not an empty string.

has-values?

(has-values? coll)
Returns true if all members of the collection has-value? This works on maps as well.

is-email?

(is-email? v)
Returns true if v is an email address

less-than?

(less-than? v n)
Returns true if the string represents a number < given.

matches-regex?

(matches-regex? v regex)
Returns true if the string matches the given regular expression

max-length?

(max-length? v len)
Returns true if v is less than or equal to the given len

min-length?

(min-length? v len)
Returns true if v is greater than or equal to the given len

not-nil?

(not-nil? v)
Returns true if v is not nil

valid-number?

(valid-number? v)
Returns true if the string can be parsed to a Long

Can you improve this documentation? These fine people already did:
Yogthos, Dmitri Sotnikov & Taylor Wood
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close