day8/re-frame-10x

[Enhancement]: Pass in (some) default settings to init!.

Closed this issue · 2 comments

What do you suggest?

We have app wide events that can be ignored by all devs. It would be great if I could pass in those events so each dev doesn't need to figure that part out.

I can manage to put up a PR for that, except I am not sure how the project owner wants to handle that default value and local storage. Should I merge events on the ignore list, prefer only defaults, or prefer local storage.

kimo-k commented

Hey @sirmspencer, thanks for the idea.

prefer local storage

This sounds like the most reasonable to me. More specifically: if the local-storage key exists, use that. If not, save the new config value to local-storage. I think this would do the trick:

modified   src/day8/re_frame_10x/events.cljs
@@ -24,7 +24,7 @@
    (rf/inject-cofx ::local-storage/load {:key "external-window-dimensions" :or {:width 800 :height 800 :top 0 :left 0}})
    (rf/inject-cofx ::local-storage/load {:key "show-epoch-traces?" :or true})
    (rf/inject-cofx ::local-storage/load {:key "using-trace?" :or true})
-   (rf/inject-cofx ::local-storage/load {:key "ignored-events" :or {}})
+   (rf/inject-cofx ::local-storage/load {:key "ignored-events" :or (into {} (get-in project-config [:re-frame-10x :ignored-events]))})
    (rf/inject-cofx ::local-storage/load {:key "low-level-trace" :or {:reagent true :re-frame true}})
    (rf/inject-cofx ::local-storage/load {:key "filtered-view-trace" :or (let [id1 (random-uuid)
                                                                               id2  (random-uuid)]

A PR would be great, if you have an easy way to implement project-config. Otherwise, I'll get started on it in a week or so.

kimo-k commented

Duplicate of #202