Hey,
I was trying to make a simple todo app with karax. The problem is that when
adding elements to my notes sequence no redraw is triggered. If i store the
notes in localStorage a redraw is triggered, however. Does anybody know whats
going on?
include karax / prelude
import json
import dom
type
Note = object
text: string
priority: Priority
Priority = enum
low, mid, high
var notes: seq[Note] = @[]
proc createApp(): VNode =
try:
let x = window.localStorage.getItem("notes")
notes = ($x).parseJson.to(seq[Note])
except:
window.localStorage.setItem("notes", $(%*(notes)))
result = buildHtml(tdiv):
tdiv:
button:
text "new note"
proc onclick(ev: Event; node: VNode) =
notes.add(Note(text: "sample text", priority: high))
#window.localStorage.setItem("notes", $(%*(notes))) #If this line
is added the code works as expected
echo "debug"
for n in notes:
tdiv:
p:
text n.text
setRenderer createApp
Run