Created
November 30, 2016 10:01
-
-
Save theblacksquid/8f43a4a17f36efeaf05930f35610fed5 to your computer and use it in GitHub Desktop.
Biwascheme FFI for localforage, still in WIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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