Reagent binds components to data using an atom. An atom is a ClojureScript reference type. An atom references an immutable value, but the reference itself is mutable, it can be changed using reset!
and swap!
to reference a different imumtable value. Changes to atom's are atomic.
The value can be retrived by dereferencing the atom using deref
or the @
prefix.
Functions can be attached to atoms to watch for changes, the function will get the atoms old and new state as arguments.
Reagent provides its own atom, reagent/atom
, which has watches setup to rerender compontents which reference the atom.