greatly simplifying how states are handled.

This commit is contained in:
Bryce Covert
2020-08-03 12:11:56 -07:00
parent bb5196b9f8
commit a22eb01008
7 changed files with 71 additions and 28 deletions

View File

@@ -43,6 +43,11 @@
(fn [db [_ multi]]
(get-in db [::status multi])))
(re-frame/reg-sub
::single
(fn [db [_ single]]
(get-in db [::status single])))
(re-frame/reg-event-db
::loading-multi
[(re-frame/path [::status]) ]
@@ -66,3 +71,24 @@
(defn reset-multi [db multi]
(assoc-in db [::status multi] {}))
(re-frame/reg-event-db
::loading
[(re-frame/path [::status]) ]
(fn [db [_ single]]
(assoc db single {:state :loading
:error nil})))
(re-frame/reg-event-db
::completed
[(re-frame/path [::status]) ]
(fn [db [_ single which]]
(assoc db single {:state nil
:error nil})))
(re-frame/reg-event-db
::error
[(re-frame/path [::status]) ]
(fn [db [_ single error]]
(assoc db single {:state :error
:error error})))