Skip to content

Instantly share code, notes, and snippets.

@martin-c
Created October 9, 2021 13:29
Show Gist options
  • Save martin-c/023b70c4296cbe415348d0150df99207 to your computer and use it in GitHub Desktop.
Save martin-c/023b70c4296cbe415348d0150df99207 to your computer and use it in GitHub Desktop.
nim asyncjs example
import asyncjs
import dom
import jsconsole
import jsffi
{.push importjs: "navigator.usb.$1()".}
proc getDevices: PromiseJs
{.pop.}
proc test: PromiseJs {.async.} =
getDevices()
proc main =
log("Hello from Nim!")
let p = await getDevices()
log(jsTypeOf p)
if isMainModule:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment