Liking cljdoc? Tell your friends :D

tuck.core


*allow-actions*cljs

Bound to false when replaying events to disable side-effects.

Bound to false when replaying events to disable side-effects.
sourceraw docstring

action!cljs

(action! action-fn & args)

Run an action function that may side-effect and schedule asynchronous actions. The first parameter of the action is the current send function. Actions only run when allow-actions is true.

Run an action function that may side-effect and schedule asynchronous actions.
The first parameter of the action is the current send function. Actions only run
when *allow-actions* is true.
sourceraw docstring

control-with-pathscljs

(control-with-paths app path-fn)
source

current-send-functioncljs

(current-send-function)

Get the current send function. Must be called from within process-event.

Get the current send function. Must be called from within process-event.
sourceraw docstring

define-assoc-eventsclj/smacro

(define-assoc-events & events-and-paths)

Define events that simply take their parameter and assoc it to the given path in the app state. Takes pairs of event name and path-vector. For example:

(define-assoc-events UpdateUserName [:user :name])

Will define an event record type called UpdateUserName which has one field and whose process-event will update the value of the field to the app state path [:user :name]. The new value will overwrite the value (if any) in the app state.

Define events that simply take their parameter and assoc it to the given path in the app state.
Takes pairs of event name and path-vector.
For example:

(define-assoc-events UpdateUserName [:user :name])

Will define an event record type called UpdateUserName which has one field and
whose process-event will update the value of the field to the app state path [:user :name].
The new value will overwrite the value (if any) in the app state.
sourceraw docstring

define-eventclj/smacro

(define-event event-record-name event-params options & body)
source

Eventcljsprotocol

process-eventcljs

(process-event this app-state)

Process this event for the current app state. Must return new state.

Process this event for the current app state. Must return new state.
source

send-async!cljs

(send-async! constructor & args)

Returns a callback which sends its argument to the UI after wrapping it with the given constructor. Must be called from within process-event.

Returns a callback which sends its argument to the UI after wrapping
it with the given constructor. Must be called from within process-event.
sourceraw docstring

send-value!cljs

(send-value! e! constructor & args)

Returns a UI event handler that sends the event's value to the UI message processing after calling constructor with it.

Returns a UI event handler that sends the event's value
to the UI message processing after calling constructor with it.
sourceraw docstring

tuckcljs

(tuck app root-component)
(tuck app root-component options)

Entrypoint for tuck. Takes in a reagent atom and a root component. The root component will be rendered with two parameters: a ui control function (for sending events to) and the current state of the app atom.

The optional options map can have the following keys: :path-fn If path-fn is provided, it is called to return a path (for update-in) for the event. If the path-fn returns nil for the event, the event is applied to the app root. Path-fn is an alternative to wrapping send functions for routing events to different parts of the state atom. :spec If specified, the app state is validate against the spec after each event. If the new state is invalid the on-invalid-state handler is called to fix it.

:on-invalid-state Handler to call when the app state after an event fails spec validation. Must return new (fixed) app state. Takes 4 arguments: the previous state, the event that caused the invalid state, the new invalid state and the spec it was validated against. Default implementation logs the event and clojure.spec explain output and returns the previous valid state.

For backwards compatibility, if options is a function, it is interpreted to mean the path-fn.

The options are evaluated once, when the component is created and changes to options don't take effect during the component's lifetime.

Entrypoint for tuck. Takes in a reagent atom and a root component.
The root component will be rendered with two parameters: a ui control
function (for sending events to) and the current state of the app atom.

The optional options map can have the following keys:
:path-fn   If path-fn is provided, it is called to return a path (for update-in)
           for the event. If the path-fn returns nil for the event, the event is
           applied to the app root. Path-fn is an alternative to wrapping send
           functions for routing events to different parts of the state atom.
:spec      If specified, the app state is validate against the spec after each
           event. If the new state is invalid the on-invalid-state handler is
           called to fix it.

:on-invalid-state
           Handler to call when the app state after an event fails spec validation.
           Must return new (fixed) app state. Takes 4 arguments: the previous state,
           the event that caused the invalid state, the new invalid state and the
           spec it was validated against.
           Default implementation logs the event and clojure.spec explain output
           and returns the previous valid state.

For backwards compatibility, if options is a function, it is interpreted to mean
the path-fn.

The options are evaluated once, when the component is created and changes to
options don't take effect during the component's lifetime.
sourceraw docstring

UpdateAtcljs

source

wrapcljs

(wrap e! wrap-constructor & args)

Wrap the given UI send function with the given constructor and optional arguments. Returns a new UI send function where each event is mapped with the constructor before being sent.

Wrap the given UI send function with the given constructor
and optional arguments. Returns a new UI send function where
each event is mapped with the constructor before being sent.
sourceraw docstring

wrap-pathcljs

(wrap-path e! & key-path)

Wrap the given UI send function with an UpdateAt event for the given key-path.

Wrap the given UI send function with an UpdateAt event for
the given key-path.
sourceraw docstring

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

× close