After fetching the list of channels and saving them in channels var, the DOM is not refreshed (only after pressing the close button, the list redraws) so for it to work I'm calling redraw.
Do I need to call redraw in situations like this one? or should it works without redraw()?
import karax / [kbase, vdom, kdom, vstyles, karax, karaxdsl, jjson], jsffi, asyncjs, jsutils, strutils
var channels: seq[tuple[name: kstring, url: kstring]] = @[]
var hide = false
proc parseM3u(text: string): seq[tuple[name: kstring, url: kstring]] =
...
proc fetchChannels(): void {.async.} =
log("fetching channels".kstring)
var res = await fetchText("https://admin.galax.be/TVkanalen/external.m3u")
channels = parseM3u($res)
log("got ".kstring & $channels.len() & " channels".kstring)
redraw()
proc createDom(): VNode =
result = buildHtml(tdiv):
tdiv(class="channel-container"):
tdiv(class="stop"):
proc onclick() =
stop()
text "Stop"
for channel in channels:
tdiv(class="channel", id=channel.url):
proc onclick() =
changeSource(channel.url)
text channel.name
fetchChannels()
setRenderer createDom
After fetching the list of channels and saving them in
channels
var, the DOM is not refreshed (only after pressing the close button, the list redraws) so for it to work I'm calling redraw.Do I need to call redraw in situations like this one? or should it works without
redraw()
?