Skip to content

Instantly share code, notes, and snippets.

@daveliepmann
Created September 23, 2014 08:23
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save daveliepmann/cf923140702c8b1de301 to your computer and use it in GitHub Desktop.
Save daveliepmann/cf923140702c8b1de301 to your computer and use it in GitHub Desktop.
HTML5 localStorage utility functions for ClojureScript. I find it makes for cleaner code when I wrap the native JS.
(ns localstorage)
(defn set-item!
"Set `key' in browser's localStorage to `val`."
[key val]
(.setItem (.-localStorage js/window) key val))
(defn get-item
"Returns value of `key' from browser's localStorage."
[key]
(.getItem (.-localStorage js/window) key))
(defn remove-item!
"Remove the browser's localStorage value for the given `key`"
[key]
(.removeItem (.-localStorage js/window) key))
@pyrmont
Copy link

pyrmont commented Mar 1, 2020

Thanks for this! Oh, the final docstring is missing a full stop at the end.

@Crowbrammer
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment