Create separate subs that ignore view namespaces

These are only needed in the Trace panel, so we don't need to pay the
cost elsewhere. This also fixes the bug where ignored view namespaces
were shown when showing all traces in the Trace panel.
This commit is contained in:
Daniel Compton 2018-01-29 01:14:31 +13:00
parent b62ed52847
commit 6465a09d08
4 changed files with 33 additions and 20 deletions

View File

@ -13,12 +13,14 @@ All notable changes to this project will be documented in this file. This change
* 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.
* Clicking on a trace's expanded information now prints the entire trace to the console instead of just the tags.
* Improved efficency of rendering views that do not need to filter out view namespaces.
### Fixed
* External windows not loading
* All app-db and subscription path expansions are now independent of each other [#134](https://github.com/Day8/re-frame-trace/issues/134).
* Layer 2/3 calculations are more accurate now. We now use the last seen layer level when a subscription runs, to inform it's layer level if it was created or destroyed.
* View namespaces that are ignored are no longer shown when showing traces for all epochs.

View File

@ -514,13 +514,16 @@
subscription-info (->> new-traces
(filter metam/subscription-re-run?)
(reduce (fn [state trace]
;; TODO: can we take any shortcuts by assuming that a sub with
;; Can we take any shortcuts by assuming that a sub with
;; multiple input signals is a layer 3? I don't *think* so because
;; one of those input signals could be a naughty subscription to app-db
;; directly.
;; If any of the input signals are app-db, it is a layer 2 sub, else 3
;; If we knew when subscription handlers were loaded/reloaded then
;; we could avoid doing most of this work, and only check the input
;; signals if we hadn't seen it before, or it had been reloaded.
(assoc-in state
[(:operation trace) :layer]
;; If any of the input signals are app-db, it is a layer 2 sub, else 3
(if (some #(= app-db-id %) (get-in trace [:tags :input-signals]))
2
3)))

View File

@ -146,10 +146,14 @@
(count traces)))
(rf/reg-sub
:traces/all-visible-traces
:traces/current-event-traces
:<- [:traces/all-traces]
:<- [:settings/filtered-view-trace]
(fn [[all-traces filtered-views] _]
:<- [:epochs/beginning-trace-id]
:<- [:epochs/ending-trace-id]
(fn [[traces beginning ending] _]
(into [] (filter #(<= beginning (:id %) ending)) traces)))
(defn filter-ignored-views [[traces filtered-views] _]
(let [munged-ns (->> filtered-views
(map (comp munge :ns-str))
(set))]
@ -158,15 +162,19 @@
(remove
(fn [trace] (and (metam/render? trace)
(contains? munged-ns (subs (:operation trace) 0 (str/last-index-of (:operation trace) "."))))))
all-traces))))
traces)))
(rf/reg-sub
:traces/current-event-traces
:<- [:traces/all-visible-traces]
:<- [:epochs/beginning-trace-id]
:<- [:epochs/ending-trace-id]
(fn [[traces beginning ending] _]
(into [] (filter #(<= beginning (:id %) ending)) traces)))
:traces/current-event-visible-traces
:<- [:traces/current-event-traces]
:<- [:settings/filtered-view-trace]
filter-ignored-views)
(rf/reg-sub
:traces/all-visible-traces
:<- [:traces/all-traces]
:<- [:settings/filtered-view-trace]
filter-ignored-views)
(rf/reg-sub
:traces/show-epoch-traces?

View File

@ -89,8 +89,8 @@
trace-detail-expansions (rf/subscribe [:traces/expansions])
beginning (rf/subscribe [:epochs/beginning-trace-id])
end (rf/subscribe [:epochs/ending-trace-id])
traces (rf/subscribe [:traces/all-traces])
current-traces (rf/subscribe [:traces/current-event-traces])
traces (rf/subscribe [:traces/all-visible-traces])
current-traces (rf/subscribe [:traces/current-event-visible-traces])
show-epoch-traces? (rf/subscribe [:traces/show-epoch-traces?])]
(fn []
(let [toggle-category-fn #(rf/dispatch [:traces/toggle-categories %])