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

@@ -12,7 +12,8 @@
[vimsical.re-frame.cofx.inject :as inject]
[auto-ap.events :as events]
[auto-ap.utils :refer [replace-by]]
[re-frame.core :as re-frame]))
[re-frame.core :as re-frame]
[auto-ap.status :as status]))
;; SUBS
@@ -54,8 +55,7 @@
(-> data
:transaction-rule-page
(update :transaction-rules (fn [rules]
(mapv ungraphql-transaction-rule rules)))))
(assoc-in [:status :loading] false))))
(mapv ungraphql-transaction-rule rules))))))))
(re-frame/reg-sub
::last-params
@@ -82,9 +82,10 @@
[with-user (re-frame/inject-cofx ::inject/sub [::params])]
(fn [{:keys [db user] ::keys [params] :as cofx} _]
{:db (-> db
(assoc-in [:status :loading] true)
(assoc-in [::last-params] params))
:graphql {:token user
:owns-state {:single ::page}
:query-obj {:venia/queries [[:transaction_rule_page
(or params {})
[[:transaction-rules default-read]
@@ -117,7 +118,7 @@
[table/table {:id :transactions
:params (re-frame/subscribe [::params])
:rule-page (re-frame/subscribe [::page])
:status (re-frame/subscribe [::subs/status])
:status @(re-frame/subscribe [::status/single ::page])
:on-params-change (fn [params]
(println "CHANGING PARAMS TO" params)
(re-frame/dispatch [::params-change params]))}]

View File

@@ -72,7 +72,7 @@
states @(re-frame/subscribe [::status/multi ::run])]
[grid/grid {:on-params-change opc
:params @(re-frame/subscribe [::table-params])
:status @status
:status status
:column-count 6}
[grid/controls {:start start :end end :count count :total total}]
[grid/table {:fullwidth true }
@@ -124,5 +124,5 @@
(defn table [params]
(r/create-class {:component-will-unmount (dispatch-event [::unmounted])
:reagent-render (fn []
:reagent-render (fn [params]
[table* params])}))