carry.core
app
(app {:keys [initial-model on-signal on-action], :as _blueprint})Constructs an app from a blueprint map with keys:
:initial-model- Initial model value, must be a map.:on-signal- Signal handler. Function of args:[model signal dispatch-signal dispatch-action]. It performs side effects, can dispatch actions and new signals. By convention, it must be able to handle:on-startand:on-stopsignals in order to be wrappable by middleware. Read-only model atom is useful for reading actual model values in async code and to subscribe to model changes. Functiondispatch-signalreturns the result of the underlyingon-signalcall. Functiondispatch-actionalways returnsnil.:on-action- Action handler. Pure function of args:[model action]. Given an action and current model value, it must return the new model value.
Returns a map with keys:
:model- An object that supportsIDerefandIWatchableprotocols.:dispatch-signal- Function with a single arg: a signal to be sent to an app. Returns the result of the underlyingon-signalcall.
entangle
(entangle r f)Creates a read-only reference which automatically syncs its value with (f @r). Returned object supports deref, add-watch and remove-watch. Arguments:
r- source reference, it must supportderef,add-watchandremove-watch(e.g. an atom or another read-only reference)f- pure function