todoapp: use local storage properly
This commit is contained in:
parent
00354cfc18
commit
6aa87e4b81
3 changed files with 40 additions and 26 deletions
|
|
@ -21,3 +21,5 @@ proc isInt*(s: cstring): bool {.asmNoStackFrame.} =
|
|||
asm """
|
||||
return s.match(/^[0-9]+$/);
|
||||
"""
|
||||
|
||||
proc parseInt*(s: cstring): int {.importcpp: "parseInt(#, 10)", nodecl.}
|
||||
|
|
|
|||
10
src/localstorage.nim
Normal file
10
src/localstorage.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
## Karax -- Single page applications for Nim.
|
||||
|
||||
## This module contains wrappers for the HTML 5 local storage.
|
||||
|
||||
proc getItem*(key: cstring): cstring {.importc: "localStorage.getItem"}
|
||||
proc setItem*(key, value: cstring) {.importc: "localStorage.setItem"}
|
||||
proc hasItem*(key: cstring): bool {.importcpp: "(localStorage.getItem(#) !== null)".}
|
||||
proc clear*() {.importc: "localStorage.clear"}
|
||||
|
||||
proc removeItem*(key: cstring) {.importc: "localStorage.removeItem".}
|
||||
Loading…
Add table
Add a link
Reference in a new issue