# Telling Elm to wait

**URL:** <https://discourse.elm-lang.org/t/telling-elm-to-wait/5239>\
**Category:** Learn\
**Created:** [February 28, 2020, 4:51pm UTC](https://discourse.elm-lang.org/t/telling-elm-to-wait/5239 "2020-02-28T16:51:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![espetro](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@espetro](https://discourse.elm-lang.org/u/espetro)\
**Post date:** [February 28, 2020, 4:51pm UTC](https://discourse.elm-lang.org/t/telling-elm-to-wait/5239/1 "2020-02-28T16:51:53Z")

</div>

Hello,

I am having a hard time trying to find a `sleep(seconds)` function similar to `setTimeout(ms, callback)` in JS or `time.sleep(ms)` in Python. So far, the most similar workaround I’ve found is to use the `http` module, that allows for a timeout when doing requests.  
Does actually something like this exist in Elm? Can this be adapted to the way the Elm architecture works?

Thanks in advance! 😊

> PS: I’m willing to do a port of the [typed.js](https://mattboldt.github.io/typed.js/) module in Elm, however I don’t get the clue of how to update one letter at a time + making Elm to wait to simulate the animation)

---

<div class="post-metadata">

**Author:** ![joelq](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/joelq/32/445_2.png) [@joelq](https://discourse.elm-lang.org/u/joelq)\
**Post date:** [February 28, 2020, 5:07pm UTC](https://discourse.elm-lang.org/t/telling-elm-to-wait/5239/2 "2020-02-28T17:07:02Z")

</div>

You’re looking for the [`Process.sleep`](https://package.elm-lang.org/packages/elm/core/latest/Process#sleep) function from `elm/core`.

This function will give you back a [`Task`](https://package.elm-lang.org/packages/elm/core/latest/Task) that you can combo with other tasks or convert to a command with [`Task.perform`](https://package.elm-lang.org/packages/elm/core/latest/Task#perform). Your `update` function will get the given message when the sleep completes.

Here’s an [executable example](https://ellie-app.com/89HccZmcK7Sa1) showing a sleep in action.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [March 9, 2020, 5:18pm UTC](https://discourse.elm-lang.org/t/telling-elm-to-wait/5239/3 "2020-03-09T17:18:12Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
