Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Js

Idiom #185 Execute function in 30 seconds

Schedule the execution of f(42) in 30 seconds.

let id = setTimeout(f, 30000, 42);

The second arg is the delay in milliseconds.

The subsequent args will be passed to the function f.

id identifies the timer created by setTimeout, and can be used to cancel the timeout.
(do (Thread/sleep 30000)
    (f 42))

Clojure is a hosted language, and relies on host interop for things like this

New implementation...
< >
programming-idioms.org