You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Changes name to a non namespaced keyword
- Adds ability to modify the task from within the event
- Betters event unregister-and-dispatch-original to work with manual registered tasks
- Tasks subscriptions returns tasks vector instead of map
Copy file name to clipboardexpand all lines: src/jtk_dvlp/re_frame/tasks.cljs
+27-14
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@
46
46
[name-or-task]
47
47
(if (map? name-or-task)
48
48
name-or-task
49
-
{::name name-or-task}))
49
+
{:name name-or-task}))
50
50
51
51
(defn-normalize-effect-key
52
52
[effect-key]
@@ -143,12 +143,14 @@
143
143
{:keys [dispatch-id ?error]}
144
144
acoeffects
145
145
146
-
task
146
+
{task-id ::id:as task}
147
147
(assoc task ::id dispatch-id)]
148
148
149
149
(if (fx-handler-run? context)
150
150
(or
151
-
(unregister-by-fxs context task fxs)
151
+
(-> context
152
+
(interceptor/assoc-effect:db (update-in db [::db:tasks task-id] merge task))
153
+
(unregister-by-fxs task fxs))
152
154
(interceptor/assoc-effect context :db (unregister db task)))
153
155
(-> context
154
156
(interceptor/assoc-effect:db (register db task))
@@ -180,11 +182,13 @@
180
182
181
183
(defnas-task
182
184
"Creates an interceptor to mark an event as task.
183
-
Give it a name of the task or map with at least a `::name` key or nil / nothing to use the event name.
185
+
Give it a name of the task or map with at least a `:name` key or nil / nothing to use the event name.
184
186
Tasks can be used via subscriptions `::tasks` and `::running?`.
185
187
186
188
Given vector `fxs` will be used to identify effects to monitor for the task. Can be the keyword of the effect or an vector of effect keyword or effect path (to handle special :fx effect) and completion keywords to hang in. Completion keys defaults to `:on-complete`, `:on-success`, `on-failure` and `on-error`. See also `set-global-default-completion-keys!` and `merge-global-default-completion-keys!`.
187
189
190
+
Within your event handler use `::task` as effect to modify your task data.
191
+
188
192
Works in combination with https://github.com/jtkDvlp/re-frame-async-coeffects. For async coeffects there is no need to define what to monitor. Coeffects will be monitored automatically."
0 commit comments