RSX Code Reference
    Preparing search index...

    Function coroutine

    • Creates a coroutine for the specified generator function that is bound to the target. The coroutine can be updated each frame by calling Coroutine#continue.

      Type Parameters

      • T
      • K extends object

      Parameters

      • targetOrGenerator: K | (() => Generator<T>)

        The this pointer to bind the generator to, or the generator if the generator should be called unbound.

      • Optionalgenerator: (this: K) => Generator<T>

        The generator.

      • OptionalonFinalize: () => void

        An optional lambda that is called when the coroutine is finalized.

      Returns Coroutine<T>

      Coroutine

      If the generator is not intended to be bound to a this pointer. It can be passed as the first argument. To get type safety pass the lambda with a type declaring this pointer:

      coroutine(this, (this:MyClass) => { ... })