From beca2881dfe0eafbd2f0ca70a999e436a3b738f6 Mon Sep 17 00:00:00 2001 From: Daniel Compton Date: Tue, 30 Jan 2018 10:49:26 +1300 Subject: [PATCH] Distinguish between subscriptions returning nil and not run --- CHANGELOG.md | 1 + src/day8/re_frame/trace/subs.cljs | 35 ++++++++++++++------------ src/day8/re_frame/trace/view/subs.cljs | 10 +++++--- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b00b356..19dc72b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ This version requires re-frame 0.10.4 to make use of the newly added Event panel * 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. +* Distinguish between subscriptions that return `nil` values and those that haven't run yet. diff --git a/src/day8/re_frame/trace/subs.cljs b/src/day8/re_frame/trace/subs.cljs index a806c46..b1607a8 100644 --- a/src/day8/re_frame/trace/subs.cljs +++ b/src/day8/re_frame/trace/subs.cljs @@ -391,22 +391,25 @@ :<- [:app-db/reagent-id] :<- [:subs/subscription-info] (fn [[traces app-db-id sub-info]] - (let [raw (map (fn [trace] (let [pod-type (sub-op-type->type trace) - path-data (get-in trace [:tags :query-v]) - ;; TODO: detect layer 2/3 for sub/create and sub/destroy - ;; This information needs to be accumulated. - layer (if (some #(= app-db-id %) (get-in trace [:tags :input-signals])) - 2 - 3)] - {:id (str pod-type (get-in trace [:tags :reaction])) - :type pod-type - :layer (get-in sub-info [(:operation trace) :layer]) - :path-data path-data - :path (pr-str path-data) - :value (get-in trace [:tags :value]) - - ;; TODO: Get not run subscriptions - })) + (let [raw (map (fn [trace] + (let [pod-type (sub-op-type->type trace) + path-data (get-in trace [:tags :query-v]) + ;; TODO: detect layer 2/3 for sub/create and sub/destroy + ;; This information needs to be accumulated. + layer (if (some #(= app-db-id %) (get-in trace [:tags :input-signals])) + 2 + 3) + sub + (-> {:id (str pod-type (get-in trace [:tags :reaction])) + :type pod-type + :layer (get-in sub-info [(:operation trace) :layer]) + :path-data path-data + :path (pr-str path-data) + ;; TODO: Get not run subscriptions + })] + (if (contains? (:tags trace) :value) + (assoc sub :value (get-in trace [:tags :value])) + sub))) traces) re-run (->> raw (filter #(= :re-run (:type %))) diff --git a/src/day8/re_frame/trace/view/subs.cljs b/src/day8/re_frame/trace/view/subs.cljs index a6cbcc1..509ca48 100644 --- a/src/day8/re_frame/trace/view/subs.cljs +++ b/src/day8/re_frame/trace/view/subs.cljs @@ -169,10 +169,12 @@ :style {:margin (css-join pod-padding pod-padding "0px" pod-padding) :overflow-x "auto" :overflow-y "hidden"} - :children [[components/simple-render - (:value pod-info) - ["sub-path" path] - ]]])] + :children [(if (contains? pod-info :value) + [components/simple-render + (:value pod-info) + ["sub-path" path]] + [rc/label :style {:font-style "italic"} :label "Subscription not run, so no value produced."] + )]])] [animated/component (animated/v-box-options {:enter-animation "accordionVertical" :leave-animation "accordionVertical"