diff --git a/src/day8/re_frame_10x/fx/local_storage.cljs b/src/day8/re_frame_10x/fx/local_storage.cljs index f776e432..ba766406 100644 --- a/src/day8/re_frame_10x/fx/local_storage.cljs +++ b/src/day8/re_frame_10x/fx/local_storage.cljs @@ -5,6 +5,7 @@ [goog.testing.storage.FakeMechanism] [cljs.reader :as reader] [clojure.string :as string] + [day8.re-frame-10x.tools.datafy :as tools.datafy] [day8.re-frame-10x.inlined-deps.re-frame.v1v1v2.re-frame.core :as rf])) (def storage-mechanism @@ -53,14 +54,14 @@ ([key] (rf/after (fn [db] - (.set storage (safe-key key) (pr-str db))))) + (.set storage (safe-key key) (tools.datafy/pr-str-safe db))))) ([key & ks] (rf/after (fn [db] (run! (fn [k] (let [v (if (vector? k) (get-in db k) (get db k))] - (.set storage (safe-key key) (pr-str v)))) + (.set storage (safe-key key) (tools.datafy/pr-str-safe v)))) ks))))) (rf/reg-cofx diff --git a/src/day8/re_frame_10x/tools/datafy.cljs b/src/day8/re_frame_10x/tools/datafy.cljs index d5872644..dfc888c9 100644 --- a/src/day8/re_frame_10x/tools/datafy.cljs +++ b/src/day8/re_frame_10x/tools/datafy.cljs @@ -41,3 +41,10 @@ (walk/postwalk #(cond-> % (keyword? %) (alias ns->alias))))) + +(defn pr-str-safe [value] + (pr-str-with-opts [value] {:flush-on-newline true + :print-readably true + :print-meta false + :print-length nil + :print-level nil}))