(wrap value reset-fn & args)
Provide a combination of value and callback, that looks like an atom.
The first argument can be any value, that will be returned when the
result is deref'ed.
The second argument should be a function, that is called with the
optional extra arguments provided to wrap, and the new value of the
resulting 'atom'.
Use for example like this:
(wrap (:foo @state)
swap! state assoc :foo)
Probably useful only for passing to child components.
Source
(defn
wrap
"Provide a combination of value and callback, that looks like an atom.\n\n The first argument can be any value, that will be returned when the\n result is deref'ed.\n\n The second argument should be a function, that is called with the\n optional extra arguments provided to wrap, and the new value of the\n resulting 'atom'.\n\n Use for example like this:\n\n (wrap (:foo @state)\n swap! state assoc :foo)\n\n Probably useful only for passing to child components."
[value reset-fn & args]
(assert-callable reset-fn)
(ratom/make-wrapper value reset-fn args))