Create localstorage helper

This commit is contained in:
chris (daiyi) 2017-08-21 13:57:50 +02:00 committed by Daniel Compton
parent a989ad0580
commit 09fdd66e71
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,16 @@
(ns day8.re-frame.trace.localstorage
(:require [goog.storage.Storage :as Storage]
[goog.storage.mechanism.HTML5LocalStorage :as html5localstore]))
(defn- storage []
(let [mech (goog.storage.mechanism.HTML5LocalStorage.)
store (goog.storage.Storage. mech)]
store))
(defn get! [key]
(let [store (storage)]
(.get store key)))
(defn set! [key val]
(let [store (storage)]
(.set store key val)))

View File

@ -2,6 +2,7 @@
(:require [day8.re-frame.trace.subvis :as subvis]
[day8.re-frame.trace.styles :as styles]
[day8.re-frame.trace.components :as components]
[day8.re-frame.trace.localstorage :as localstorage]
[re-frame.trace :as trace :include-macros true]
[cljs.pprint :as pprint]
[clojure.string :as str]