Ruslan Ustitc
Ruslan Ustitc

Reputation: 85

How to sleep in Gleam?

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?

Upvotes: 0

Views: 429

Answers (1)

Ruslan Ustitc
Ruslan Ustitc

Reputation: 85

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)

Upvotes: 2

Related Questions