# Waiting in coroutines

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

`yield` waits for a tween or a timer:

    func Die() coroutine {
      yield tween.ToFloat(node, "SpriteRenderer.Tint.a", 0, 0.2, curve.OutQuad)
      node.Destroy()
    }

    func Spawner() coroutine {
      t := timer.New(2).Repeat(-1)
      for {
        yield t
        spawn()
      }
    }

How waits resume:

- `yield t` resumes on the frame after the tween ends or is stopped, or after the timer fires or is cancelled.
- A repeating timer wakes the coroutine on every fire.
- A `nil` or finished handle resumes on the next frame.
- Woken coroutines run with the other game-time coroutines, so they wait while the game is paused even when the tween or timer itself is unscaled. In a pause menu, wait with `yield waitUnscaled(s)`.

There is no polling: a coroutine parked on a handle costs nothing until the handle wakes it.
