Asynchronous code (javascript's setTimeout equivalent) in Nim

415 views Asked by At

What would be a nim equivalent of this javascript program with setTimeout? Please don't hack with sleep(1000) and keep the code asynchronous.

setTimeout(
    function()
    {
        console.log("Hello world")
    },
    1000
)
1

There are 1 answers

1
dom96 On

The asyncdispatch module defines a sleepAsync function: https://nim-lang.org/docs/asyncdispatch.html#sleepAsync,int

You can use that to create a setTimeout equivalent.