Change sub filter to ignore unchanged l2 subs

This commit is contained in:
Daniel Compton 2018-01-31 01:07:55 +13:00
parent d652ef17e3
commit d5060fc814
6 changed files with 34 additions and 16 deletions

View File

@ -14,6 +14,7 @@ This version requires re-frame 0.10.4 to make use of the newly added Event panel
### Changed ### Changed
* In the subs panel "Ignore **n** layer 2 subs" is now "Ignore **n** unchanged layer 2 subs". This is a more useful filter, as you can filter out noisy layer 2 subscriptions, while still seeing the changes that do happen to layer 2 subs.
* The version of Garden that re-frame-trace uses is now bundled as a source dependency so you should no longer get conflicts if you use Garden 2. * The version of Garden that re-frame-trace uses is now bundled as a source dependency so you should no longer get conflicts if you use Garden 2.
* Refactored re-frame-trace trace parsing internals to incrementally parse new traces. * Refactored re-frame-trace trace parsing internals to incrementally parse new traces.
* Clicking on a trace's expanded information now prints the entire trace to the console instead of just the tags. * Clicking on a trace's expanded information now prints the entire trace to the console instead of just the tags.

View File

@ -593,7 +593,7 @@
;; ;;
(rf/reg-event-db (rf/reg-event-db
:subs/ignore-unchanged-subs? :subs/ignore-unchanged-l2-subs?
[(rf/path [:subs :ignore-unchanged-subs?])] [(rf/path [:subs :ignore-unchanged-subs?])]
(fn [_ [_ ignore?]] (fn [_ [_ ignore?]]
ignore?)) ignore?))

View File

@ -162,12 +162,12 @@
(= :render (:op-type trace))) (= :render (:op-type trace)))
(defn unchanged-l2-subscription? [sub] (defn unchanged-l2-subscription? [sub]
;; TODO: check if value changed
(and (and
(= :re-run (:type sub)) (= :re-run (:type sub))
(= 2 (:layer sub)) (= 2 (:layer sub))
;; Show any subs that ran multiple times (and (contains? sub :previous-value)
(nil? (:run-times sub)))) (contains? sub :value)
(= (:previous-value sub) (:value sub)))))
(defn finish-run? [event] (defn finish-run? [event]

View File

@ -464,7 +464,7 @@
(rf/reg-sub (rf/reg-sub
:subs/visible-subs :subs/visible-subs
:<- [:subs/all-subs] :<- [:subs/all-subs]
:<- [:subs/ignore-unchanged-subs?] :<- [:subs/ignore-unchanged-l2-subs?]
(fn [[all-subs ignore-unchanged-l2?]] (fn [[all-subs ignore-unchanged-l2?]]
(if ignore-unchanged-l2? (if ignore-unchanged-l2?
(remove metam/unchanged-l2-subscription? all-subs) (remove metam/unchanged-l2-subscription? all-subs)
@ -509,7 +509,7 @@
(count (filter metam/unchanged-l2-subscription? subs)))) (count (filter metam/unchanged-l2-subscription? subs))))
(rf/reg-sub (rf/reg-sub
:subs/ignore-unchanged-subs? :subs/ignore-unchanged-l2-subs?
:<- [:subs/root] :<- [:subs/root]
(fn [subs _] (fn [subs _]
(:ignore-unchanged-subs? subs true))) (:ignore-unchanged-subs? subs true)))

View File

@ -29,3 +29,21 @@
([label x] ([label x]
(js/console.log label x) (js/console.log label x)
x)) x))
(defn pluralize
"Return a pluralized phrase, appending an s to the singular form if no plural is provided.
For example:
(pluralize 5 \"month\") => \"5 months\"
(pluralize 1 \"month\") => \"1 month\"
(pluralize 1 \"radius\" \"radii\") => \"1 radius\"
(pluralize 9 \"radius\" \"radii\") => \"9 radii\"
From https://github.com/flatland/useful/blob/194950/src/flatland/useful/string.clj#L25-L33"
[num singular & [plural]]
(str num " " (if (= 1 num) singular (or plural (str singular "s")))))
(defn pluralize-
"Same as pluralize, but doesn't prepend the number to the pluralized string."
[num singular & [plural]]
(if (= 1 num)
singular
(or plural (str singular "s"))))

View File

@ -56,7 +56,7 @@
re-run-count (rf/subscribe [:subs/re-run-count]) re-run-count (rf/subscribe [:subs/re-run-count])
destroyed-count (rf/subscribe [:subs/destroyed-count]) destroyed-count (rf/subscribe [:subs/destroyed-count])
not-run-count (rf/subscribe [:subs/not-run-count]) not-run-count (rf/subscribe [:subs/not-run-count])
ignore-unchanged? (rf/subscribe [:subs/ignore-unchanged-subs?]) ignore-unchanged-l2-subs? (rf/subscribe [:subs/ignore-unchanged-l2-subs?])
ignore-unchanged-l2-count (rf/subscribe [:subs/unchanged-l2-subs-count])] ignore-unchanged-l2-count (rf/subscribe [:subs/unchanged-l2-subs-count])]
[rc/h-box [rc/h-box
:justify :between :justify :between
@ -89,13 +89,12 @@
:border "1px solid #e3e9ed" :border "1px solid #e3e9ed"
:border-radius border-radius} :border-radius border-radius}
:children [[rc/checkbox :children [[rc/checkbox
:model ignore-unchanged? :model ignore-unchanged-l2-subs?
;; TODO: change from l2 subs to ignored l2 subs :label [:span "Ignore " [:b {:style {:font-weight "700"}} @ignore-unchanged-l2-count] " unchanged" [:br]
:label [:span "Ignore " [:b {:style {:font-weight "700"}} @ignore-unchanged-l2-count] #_" unchanged" [:br] [rc/link {:label (str "layer 2 " (utils/pluralize- @ignore-unchanged-l2-count "sub"))
[rc/link {:label "layer 2 subs"
:href "https://github.com/Day8/re-frame-trace/blob/master/docs/HyperlinkedInformation/UnchangedLayer2.md"}]] :href "https://github.com/Day8/re-frame-trace/blob/master/docs/HyperlinkedInformation/UnchangedLayer2.md"}]]
:style {:margin-top "6px"} :style {:margin-top "6px"}
:on-change #(rf/dispatch [:subs/ignore-unchanged-subs? %])]]]]])) :on-change #(rf/dispatch [:subs/ignore-unchanged-l2-subs? %])]]]]]))
(defn pod-header [{:keys [id type layer path open? diff? run-times]}] (defn pod-header [{:keys [id type layer path open? diff? run-times]}]
[rc/h-box [rc/h-box
@ -270,10 +269,10 @@
(defn render [] (defn render []
[] []
[rc/v-box [rc/v-box
:size "1" :size "1"
:style {:margin-right common/gs-19s :style {:margin-right common/gs-19s
;:overflow "hidden" ;:overflow "hidden"
} }
:children [[panel-header] :children [[panel-header]
[pod-section] [pod-section]
[rc/gap-f :size pod-gap] [rc/gap-f :size pod-gap]