https://github.com/jtkdvlp/re-frame-tasks
A re-frame interceptor and helpers to register / unregister (background-)tasks
https://github.com/jtkdvlp/re-frame-tasks
re-frame tasks tasks-list
Last synced: 10 months ago
JSON representation
A re-frame interceptor and helpers to register / unregister (background-)tasks
- Host: GitHub
- URL: https://github.com/jtkdvlp/re-frame-tasks
- Owner: jtkDvlp
- License: mit
- Created: 2020-08-27T22:29:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-01-30T22:47:21.000Z (12 months ago)
- Last Synced: 2025-03-02T16:49:53.877Z (11 months ago)
- Topics: re-frame, tasks, tasks-list
- Language: Clojure
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://clojars.org/jtk-dvlp/re-frame-tasks)
[](https://cljdoc.org/d/jtk-dvlp/re-frame-tasks/CURRENT)
[](https://github.com/jtkDvlp/re-frame-tasks/blob/master/LICENSE)
# Tasks interceptor / helpers for re-frame
Interceptor and helpers to register and unregister (background-)tasks (FXs) in your app-state / app-db to list tasks and / or block single ui parts or the whole ui.
## Features
* register / unregister tasks / fxs via one line or global interceptor injection
* support multiple and any fx on-completion keys via registration
* subscriptions for tasks list and running task boolean
* running task boolean can be quick filtered by task name
* events to register / unregister tasks yourself
* helpers to register / unregister tasks into db yourself
Also works for async coeffect injections, see https://github.com/jtkDvlp/re-frame-async-coeffects.
## Getting started
### Get it / add dependency
Add the following dependency to your `project.clj`:
[](https://clojars.org/jtk-dvlp/re-frame-tasks)
### Usage
See api docs [](https://cljdoc.org/d/jtk-dvlp/re-frame-tasks/CURRENT)
```clojure
(ns ^:figwheel-hooks jtk-dvlp.your-project
(:require
[cljs.pprint]
[cljs.core.async :refer [timeout]]
[jtk-dvlp.async :refer [go > args
(apply some-async-stuff)
(
[:button {:on-click #(rf/dispatch [:some-event])}
"exec some event"]
[:button {:on-click #(rf/dispatch [:some-bad-event])}
"exec some bad event"]
[:button {:on-click #(rf/dispatch [:some-other-bad-event])}
"exec some other bad event"]
[:ul "task list " (count @tasks)
;; task is a map of `::tasks/id`, `:name`, `:event and the
;; data you carry via `::task` fx from within the event
(for [{:keys [::tasks/id] :as task} @tasks]
^{:key id}
[:li [:pre (with-out-str (cljs.pprint/pprint task))]])]
(when @block-ui?
[:div "this div blocks the UI if there are running tasks"])])))
```
## Appendix
I´d be thankful to receive patches, comments and constructive criticism.
Hope the package is useful :-)