(as-task)(as-task name-or-task)(as-task name-or-task effects)(as-task name-or-task effects wait-for-tasks)(as-task name-or-task effects wait-for-tasks debounce-ms)Creates an interceptor to mark an event and its effects as task. Also see wait-for to wait for task.
Give it a name of the task or map with at least a :name key or nil / nothing to use the event name.
Tasks can be used via subscriptions tasks-sub and running?-sub.
Given vector effects will be used to identify effects to monitor for the task. Can be the keyword of
the effect or an vector of effects path (to handle special :fx effect). Completion keys must be
registered by reg-completion-keys-for-effect for the effects.
Given sugar wait-for-tasks to also inject wait-for interceptor, see documentation wait-for for
details. Given sugar debounce-ms to also inject debounce interceptor, see documentation debounce
for details.
Within your event handler use ::task as effect to modify your task data.
A task carries ::id, its :name, the event that opened it under
::event and whatever the ::task effect added. All of it is yours to
read via get-tasks or tasks-sub.
See the *-original-event functions to handle as-tasks effect completion handlers.
See attach-after-event to attach events to call after task completion.
Creates an interceptor to mark an event and its effects as task. Also see [[wait-for]] to wait for task. Give it a name of the task or map with at least a `:name` key or nil / nothing to use the event name. Tasks can be used via subscriptions [[tasks-sub]] and [[running?-sub]]. Given vector `effects` will be used to identify effects to monitor for the task. Can be the keyword of the effect or an vector of effects path (to handle special `:fx` effect). Completion keys must be registered by [[reg-completion-keys-for-effect]] for the effects. Given sugar `wait-for-tasks` to also inject [[wait-for]] interceptor, see documentation [[wait-for]] for details. Given sugar `debounce-ms` to also inject [[debounce]] interceptor, see documentation [[debounce]] for details. Within your event handler use `::task` as effect to modify your task data. A task carries `::id`, its `:name`, the event that opened it under `::event` and whatever the `::task` effect added. All of it is yours to read via [[get-tasks]] or [[tasks-sub]]. See the `*-original-event` functions to handle as-tasks effect completion handlers. See [[attach-after-event]] to attach events to call after task completion.
(assoc-orignal-event event original-event)Assocs original-event within maybe task event, returns maybe modified event.
Assocs `original-event` within maybe task `event`, returns maybe modified `event`.
(attach-after-event db id-or-task event)Attaches event to call after task completion.
Attaches event to call after task completion.
(claim context claim-key)Keeps the task of this event run registered although the run is about to end without effects to wait for -- because the caller takes over and will continue it later.
claim-key identifies the claim and has to be unique among the claims
of one task; an id the caller already holds per suspension does nicely.
Give the same key back to release.
WATCHOUT: Whoever claims, releases -- in every outcome. A claim that is
never given back leaves the task registered for good, and anything waiting
for it waits for good. Where there is no run left to release in, an
error path typically, there is the release-event.
Keeps the task of this event run registered although the run is about to end without effects to wait for -- because the caller takes over and will continue it later. `claim-key` identifies the claim and has to be unique among the claims of one task; an id the caller already holds per suspension does nicely. Give the same key back to [[release]]. WATCHOUT: Whoever claims, releases -- in every outcome. A claim that is never given back leaves the task registered for good, and anything waiting for it waits for good. Where there is no run left to release in, an error path typically, there is the [[release-event]].
(debounce ms)Creates an interceptor to debounce event calls within ms.
To not debounce but call event add event vector meta ::debounce {:flush? true}.
Creates an interceptor to debounce event calls within `ms`.
To not debounce but call event add event vector meta `::debounce {:flush? true}`.(dispatch-debounce! {:keys [ms] [event :as dispatch] :dispatch :as args})re-frame effect to debounce dispatch within ms.
re-frame effect to debounce `dispatch` within `ms`.
(ensure-original-event event original-event)Ensures an original-event for direct use or with task.
Ensures an `original-event` for direct use or with task.
re-frame effect to flush debounced dispatch.
re-frame effect to flush debounced `dispatch`.
(get-original-event event)Gets original event of task event or event itself.
Gets original event of task event or `event` itself.
(get-task db id-or-task)Gets task in app-db via id-or-task. Can return nil.
Gets task in app-db via `id-or-task`. Can return nil.
(get-task-by-name db name)Gets task in app-db via name. Can return nil.
Gets task in app-db via `name`. Can return nil.
(get-tasks db)Gets all tasks in app-db. Can return nil. Also see subscription tasks-sub.
Gets all tasks in app-db. Can return nil. Also see subscription [[tasks-sub]].
(reg-completion-keys-for-effect effect-key & completion-keys)Registers effect completion keys to use with as-task.
Registers effect completion keys to use with `as-task`.
(register db {:keys [:jtk-dvlp.re-frame.tasks/id] :as task})Registers task within app-db. Also see event register-event.
Tasks can be used via subscriptions tasks-sub and running?-sub.
Registers task within app-db. Also see event [[register-event]]. Tasks can be used via subscriptions [[tasks-sub]] and [[running?-sub]].
re-frame event to register task. See register.
re-frame event to register `task`. See [[register]].
(release context claim-key)Gives back a claim taken with claim, from within an event run. Use the
release-event where there is no run to hand it back in.
Gives back a claim taken with [[claim]], from within an event run. Use the [[release-event]] where there is no run to hand it back in.
re-frame event to give back a claim outside of an event run, see
claim. Completes the task when it was the last one.
re-frame event to give back a claim outside of an event run, see [[claim]]. Completes the task when it was the last one.
(resume event task-id)Marks event as the continuation of the task task-id, so dispatching
it picks that task up again instead of opening a second one. wait-for
lets such an event past the very task it continues.
Marks `event` as the continuation of the task `task-id`, so dispatching it picks that task up again instead of opening a second one. [[wait-for]] lets such an event past the very task it continues.
(running? db)(running? db name)Checks for running task in app-db also filtered via name. Also see
subscription running?-sub.
Checks for running task in app-db also filtered via `name`. Also see subscription [[running?-sub]].
re-frame subscription for running tasks optional filtered by given name.
re-frame subscription for running tasks optional filtered by given `name`.
(some-original-event? event)Checks for some original event of task or event itself.
Checks for some original event of task or `event` itself.
(task-event? event)Checks if event is task based.
Checks if event is task based.
(task-id context)Id of the task this event run belongs to, or nil when the run carries
none. Hand it to whatever will continue the run later, see resume.
Id of the task this event run belongs to, or nil when the run carries none. Hand it to whatever will continue the run later, see [[resume]].
re-frame subscription for all tasks.
re-frame subscription for all tasks.
(unregister db id-or-task)Unregisters task within app-db. Also see event unregister-event.
Tasks can be used via subscriptions tasks-sub and running?-sub.
WATCHOUT: This drops the task including its ::after-events; calling
the events is up to the caller. Everything here goes through
complete-task, which does both. Whoever calls this one directly has to
dispatch the events, or whatever waited on the task waits for good, and
nothing says a word.
Unregisters task within app-db. Also see event [[unregister-event]]. Tasks can be used via subscriptions [[tasks-sub]] and [[running?-sub]]. WATCHOUT: This drops the task including its `::after-events`; calling the events is up to the caller. Everything here goes through `complete-task`, which does both. Whoever calls this one directly has to dispatch the events, or whatever waited on the task waits for good, and nothing says a word.
re-frame event to unregister task. See unregister.
re-frame event to unregister `task`. See [[unregister]].
(update-original-event event f & args)Updates original event of maybe task event, returns maybe modified event.
Updates original event of maybe task `event`, returns maybe modified `event`.
(wait-for)(wait-for tasks)(wait-for tasks debounce-ms)Creates an interceptor to wait for task aka. queue event execution during running tasks.
tasks can be
:any for any taskCan be injected multiple times, consider injection order.
Can be used as global interceptor, consider there is no direct reversal allow / pass
functionality. To not wait for tasks but call event add event vector meta
::wait-for {:ignore-tasks #{task-name ,,,}}.
Sugar debounce-ms to also inject debounce interceptor.
Creates an interceptor to wait for task aka. queue event execution during running `tasks`.
`tasks` can be
- `:any` for any task
- a task name
- a collection of task names
- a 2-argument function given coeffects and all running tasks to filter for blocking tasks
Can be injected multiple times, consider injection order.
Can be used as global interceptor, consider there is no direct reversal allow / pass
functionality. To not wait for tasks but call event add event vector meta
`::wait-for {:ignore-tasks #{task-name ,,,}}`.
Sugar `debounce-ms` to also inject [[debounce]] interceptor.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |