I need to suspend a thread (or process) for a specific duration. In other languages like Python or JavaScript, this can be achieved using time.sleep()
or setTimeout()
, respectively.
What is the equivalent method in Gleam to achieve this? Does Gleam have a built-in way to suspend execution, or do I need to use an external library or Erlang interop for this functionality?
Use sleep
function from gleam/erlang/process.
Add Gleam Erlang library:
gleam add gleam_erlang
Import the package:
import gleam/erlang/process
Specify time in milliseconds:
process.sleep(10)