Remove all local ratom state for storing traces
This commit is contained in:
parent
d9d8ec049d
commit
3235e5a50d
|
@ -114,7 +114,7 @@
|
|||
;; Schedule a trace to be emitted after a render if there is nothing else scheduled after that render.
|
||||
;; This signals the end of the epoch.
|
||||
|
||||
#_ (swap! do-after-render-trace-scheduled?
|
||||
#_(swap! do-after-render-trace-scheduled?
|
||||
(fn [scheduled?]
|
||||
(js/console.log "Setting up scheduled after" scheduled?)
|
||||
(if scheduled?
|
||||
|
@ -157,7 +157,7 @@
|
|||
|
||||
(def ease-transition "left 0.2s ease-out, top 0.2s ease-out, width 0.2s ease-out, height 0.2s ease-out")
|
||||
|
||||
(defn devtools-outer [traces opts]
|
||||
(defn devtools-outer [opts]
|
||||
;; Add clear button
|
||||
;; Filter out different trace types
|
||||
(let [position (r/atom :right)
|
||||
|
@ -217,7 +217,7 @@
|
|||
:transition transition}}
|
||||
[:div.panel-resizer {:style (resizer-style draggable-area)
|
||||
:on-mouse-down #(reset! dragging? true)}]
|
||||
[container/devtools-inner traces opts]]]))})))
|
||||
[container/devtools-inner opts]]]))})))
|
||||
|
||||
|
||||
(defn panel-div []
|
||||
|
@ -233,7 +233,7 @@
|
|||
|
||||
(defn inject-devtools! []
|
||||
(styles/inject-trace-styles js/document)
|
||||
(r/render [devtools-outer events/traces {:panel-type :inline
|
||||
(r/render [devtools-outer {:panel-type :inline
|
||||
:debug? debug?}] (panel-div)))
|
||||
|
||||
(defn init-db! []
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
[day8.re-frame.trace.metamorphic :as metam]
|
||||
[re-frame.trace]))
|
||||
|
||||
(def default-number-of-epochs-to-retain 5)
|
||||
|
||||
(defonce traces (r/atom []))
|
||||
|
||||
(defn log-trace? [trace]
|
||||
(let [render-operation? (or (= (:op-type trace) :render)
|
||||
(= (:op-type trace) :componentWillUnmount))
|
||||
|
@ -121,7 +117,7 @@
|
|||
(let [num (js/parseInt num-str)
|
||||
num (if (and (not (js/isNaN num)) (pos-int? num))
|
||||
num
|
||||
default-number-of-epochs-to-retain)]
|
||||
5)]
|
||||
(localstorage/save! "retained-epochs" num)
|
||||
(assoc-in db [:settings :number-of-epochs] num))))
|
||||
|
||||
|
@ -206,8 +202,7 @@
|
|||
[(r/create-class
|
||||
{:display-name "devtools outer external"
|
||||
:reagent-render (fn []
|
||||
[container/devtools-inner traces {:panel-type :popup}
|
||||
])})]
|
||||
[container/devtools-inner {:panel-type :popup}])})]
|
||||
app)))
|
||||
|
||||
(defn open-debugger-window
|
||||
|
@ -494,37 +489,17 @@
|
|||
(sort-by :id))]
|
||||
(let [number-of-epochs-to-retain (get-in db [:settings :number-of-epochs])
|
||||
events-to-ignore (->> (get-in db [:settings :ignored-events]) vals (map :event-id) set)
|
||||
|
||||
|
||||
#_ #_ total-traces (get-in db [:traces :total-traces])
|
||||
#_ #_ new-total-traces (+ total-traces (count new-traces))]
|
||||
#_(swap! total-traces + (count new-traces))
|
||||
;; TODO: add this back in once the algorithm is better defined
|
||||
#_(swap! traces
|
||||
(fn [existing]
|
||||
(let [new (reduce conj existing new-traces)
|
||||
size (count new)]
|
||||
(if (< 8000 size)
|
||||
(let [new2 (subvec new (- size 4000))]
|
||||
(if (< new-total-traces 40000) ;; Create a new vector to avoid structurally sharing all traces forever
|
||||
(do (comment "Total traces set to 0") ;(reset! total-traces 0)
|
||||
(into [] new2))))
|
||||
new))))
|
||||
(swap! traces (fn [existing] (reduce conj existing new-traces)))
|
||||
;; TODO: there is a bit of double handling here with retaining the last n epochs,
|
||||
;; that will be cleaned up when the epoch parsing is refactored.
|
||||
(let [matches (:matches (metam/parse-traces @traces))
|
||||
existing-traces (get-in db [:traces :all-traces])
|
||||
new-traces (reduce conj existing-traces new-traces)
|
||||
matches (:matches (metam/parse-traces new-traces))
|
||||
matches (remove (fn [match]
|
||||
(let [event (get-in (metam/matched-event match) [:tags :event])]
|
||||
(contains? events-to-ignore (first event)))) matches)
|
||||
retained-epochs (take-last number-of-epochs-to-retain matches)
|
||||
first-id-to-retain (:id (ffirst retained-epochs))
|
||||
new-traces (into [] (drop-while #(< (:id %) first-id-to-retain)) @traces)]
|
||||
(reset! traces new-traces)
|
||||
;; Reset total-traces count to new traces
|
||||
#_(reset! total-traces (count new-traces))
|
||||
new-traces (into [] (drop-while #(< (:id %) first-id-to-retain)) new-traces)]
|
||||
(rf/dispatch [:traces/update-traces new-traces])
|
||||
(rf/dispatch [:epochs/update-epochs {:matches retained-epochs}]))))
|
||||
(rf/dispatch [:epochs/update-epochs {:matches retained-epochs}])))
|
||||
db))
|
||||
|
||||
(rf/reg-event-db
|
||||
|
@ -567,7 +542,6 @@
|
|||
:epochs/reset
|
||||
(fn [db]
|
||||
(re-frame.trace/reset-tracing!)
|
||||
(reset! traces [])
|
||||
(dissoc db :epochs :traces)))
|
||||
|
||||
(rf/reg-event-db
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
[rc/line :size "2px" :color common/sidebar-heading-divider-color]
|
||||
[right-hand-buttons external-window?]]))
|
||||
|
||||
(defn devtools-inner [traces opts]
|
||||
(defn devtools-inner [opts]
|
||||
(let [selected-tab (rf/subscribe [:settings/selected-tab])
|
||||
panel-type (:panel-type opts)
|
||||
external-window? (= panel-type :popup)
|
||||
|
@ -156,11 +156,11 @@
|
|||
;:overflow "auto" ;; TODO: Might have to put this back or add scrolling within the panels
|
||||
}
|
||||
:children [(case @selected-tab
|
||||
:event [event/render traces]
|
||||
:event [event/render]
|
||||
:app-db [app-db/render db/app-db]
|
||||
:subs [subs/render]
|
||||
:views [views/render]
|
||||
:traces [traces/render traces]
|
||||
:traces [traces/render]
|
||||
:timing [timing/render]
|
||||
:debug [debug/render]
|
||||
:settings [settings/render]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
(:require [day8.re-frame.trace.utils.re-com :as rc]
|
||||
[day8.re-frame.trace.metamorphic :as metam]))
|
||||
|
||||
(defn render [traces]
|
||||
(defn render []
|
||||
[rc/v-box
|
||||
:padding "12px 0px"
|
||||
:children [[rc/label :label "Event"]
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
[:td.trace--meta.trace--details-icon
|
||||
{:on-click #(.log js/console tags)}]]))))))))
|
||||
|
||||
(defn render [traces]
|
||||
(defn render []
|
||||
(let [filter-input (r/atom "")
|
||||
filter-items (rf/subscribe [:traces/filter-items])
|
||||
filter-type (r/atom :contains)
|
||||
|
|
Loading…
Reference in New Issue