# Use of Timer

**URL:** <https://discourse.julialang.org/t/use-of-timer/59350>\
**Category:** General Usage\
**Created:** [April 15, 2021, 3:15pm UTC](https://discourse.julialang.org/t/use-of-timer/59350 "2021-04-15T15:15:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javise](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@Javise](https://discourse.julialang.org/u/Javise)\
**Post date:** [April 15, 2021, 3:15pm UTC](https://discourse.julialang.org/t/use-of-timer/59350/1 "2021-04-15T15:15:39Z")

</div>

Hello,

I would like to make a text appear and have each letter appear at X seconds intervals. I think it is possible to do this with the Timer function but I don’t know how to use it. I had thought of using an array that would contain the letters but how to do it ?  
Still concerning the use of Timer: how to make a function run automatically Y seconds after another function has been run?

The only example I found about Timer is this one:

```julia
begin
           i = 0
           cb(timer) = (global i += 1; println(i))
           t = Timer(cb, 2, interval=0.2)
           wait(t)
           sleep(0.5)
           close(t)
       end

```

Thank you

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [April 15, 2021, 4:02pm UTC](https://discourse.julialang.org/t/use-of-timer/59350/2 "2021-04-15T16:02:34Z")

</div>

You could rig something up using `Timer`, but it’s much simpler to do this without:

```julia
function print_slowly(s, interval)
    for c in s
        sleep(interval)
        print(c)
    end
end

```

Is there a particular reason you’d like to use `Timer` for this? The `Timer`-based solution is below:

```julia
function print_slowly(s, interval)
    timer = Timer(0; interval=interval)
    for c in s
        wait(timer)
        print(c)
    end
    close(timer)
end

```

---

<div class="post-metadata">

**Author:** ![Javise](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@Javise](https://discourse.julialang.org/u/Javise)\
**Post date:** [April 15, 2021, 6:15pm UTC](https://discourse.julialang.org/t/use-of-timer/59350/3 "2021-04-15T18:15:19Z")

</div>

No there is no particular reason, I thought it was the only solution.  
Your solution works but since I work with Pluto and use “with\_terminal() do”, the function runs in full and the result appears in full. It does not appear little by little respecting the intervals.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [April 15, 2021, 8:14pm UTC](https://discourse.julialang.org/t/use-of-timer/59350/4 "2021-04-15T20:14:13Z")

</div>

I don’t think there’s any way to do this within Pluto. See the answer to the question “Can I  
use **`@async`** to update values reactively on demand?” on this page:

> **[⚡ Writing and running code](https://github.com/fonsp/Pluto.jl/wiki/%E2%9A%A1-Writing-and-running-code)**
>
> 🎈 Simple reactive notebooks for Julia. Contribute to fonsp/Pluto.jl development by creating an account on GitHub.
