Skip to content

Instantly share code, notes, and snippets.

@theblacksquid
Created November 30, 2016 10:01
Show Gist options
  • Save theblacksquid/8f43a4a17f36efeaf05930f35610fed5 to your computer and use it in GitHub Desktop.
Save theblacksquid/8f43a4a17f36efeaf05930f35610fed5 to your computer and use it in GitHub Desktop.
Biwascheme FFI for localforage, still in WIP
(js-load "https://cdnjs.cloudflare.com/ajax/libs/localforage/1.4.3/localforage.min.js" "window")
; the callback argument is passed two
; arguments, errors, and the value of
; the resulting function
; i.e. (lambda (err val) body), unless
; otherwise stated
; creates a new entry in the store
(define set-item!
(lambda (key value callback)
(js-call (js-eval "localforage.setItem") key value callback)))
; gets the value of key, and is
; passed to the
(define get-item
(lambda (key callback)
(js-call (js-eval "localforage.getItem") key callback)))
(define remove-item
(lambda (key callback)
(js-call (js-eval "localforage.removeItem") key callback)))
(define clear-storage
(lambda (callback)
(js-call (js-eval "localforage.clear") callback)))
(get-item "name" (js-closure (lambda (err val) (alert val))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment