Call a function repeatedly with a delay between each call.
Works on both Erlang and JavaScript runtimes!
gleam add repeatedly
import repeatedly
pub fn main() {
// Print every 500ms
let repeater = repeatedly.call(500, Nil, fn(_state, i) {
io.println("Call number " <> int.to_string(i))
})
// And at some point later, stop it
repeatedly.stop(repeater)
}
Further documentation can be found at https://hexdocs.pm/repeatedly.