• Wait for a number of ticks.

    Returns a Generator that completes after it has been resumed n timed.

    A "tick" is a call to Schedule.tick. When placed in a Schedule this returns a Generator that completes after n calls to Schedule.tick. If Schedule.tick is called once per frame, for example in requestAnimationFrame, then a tick corresponds to a frame.

    Parameters

    • n: number

      How many ticks to wait

    Returns Generator<any, void, unknown>

    Example

    const schedule = new Schedule()
    schedule.add(function* () {
    console.log("Hello")
    yield* frames(4)
    console.log("World")
    })
    schedule.tick() // prints out Hello
    schedule.tick()
    schedule.tick()
    schedule.tick()
    schedule.tick() // prints out World