Should improve perf somewhat

This commit is contained in:
Bryce Covert
2020-05-02 08:09:26 -07:00
parent 532e35bb50
commit 5643b98b13
6 changed files with 116 additions and 91 deletions

View File

@@ -28,17 +28,25 @@
(fn [db]
(-> db ::payment-page)))
(re-frame/reg-sub
::last-params
(fn [db]
(-> db ::last-params)))
(re-frame/reg-sub
::params
:<- [::last-params]
:<- [::subs/client]
:<- [::side-bar/filter-params]
:<- [::table/table-params]
(fn [[client filter-params table-params]]
(re-frame/dispatch [::params-change])
(cond-> {}
client (assoc :client-id (:id client))
(seq filter-params) (merge filter-params)
(seq table-params) (merge @(re-frame/subscribe [::table/table-params])))))
(fn [[last-params client filter-params table-params]]
(let [params (cond-> {}
client (assoc :client-id (:id client))
(seq filter-params) (merge filter-params)
(seq table-params) (merge table-params))]
(when (not= last-params params)
(re-frame/dispatch [::params-change]))
params)))
(re-frame/reg-event-fx
::params-change
@@ -104,11 +112,9 @@
:status (re-frame/subscribe [::subs/status])
:void-event [::void-check]}]]))
(defn payments-page []
(reagent/create-class
{:display-name "payments-page"
:component-did-mount #(re-frame/dispatch [::params-change {}])
:component-will-unmount #(re-frame/dispatch [::unmounted])
:reagent-render
(fn []