MadelineProtoDocs/docs/PHP/danog/MadelineProto/Coroutine.md

1.6 KiB

title: danog\MadelineProto\Coroutine: Creates a promise from a generator function yielding promises. description: When a promise is yielded, execution of the generator is interrupted until the promise is resolved. A success value is sent into the generator, while a failure reason is thrown into the generator. Using a coroutine, asynchronous code can be written without callbacks and be structured like synchronous code.

danog\MadelineProto\Coroutine

Back to index

Author: Daniil Gentili daniil@daniil.it

Creates a promise from a generator function yielding promises.

When a promise is yielded, execution of the generator is interrupted until the promise is resolved. A success value is sent into the generator, while a failure reason is thrown into the generator. Using a coroutine, asynchronous code can be written without callbacks and be structured like synchronous code.

Method list:

  • fail(\Throwable $reason): void
  • offsetGet(mixed $offset): \Amp\Promise
  • getTrace(): array
  • getFrame(): array
  • jsonSerialize(): string
  • onResolve()

Methods:

fail(\Throwable $reason): void

Parameters:

  • $reason: \Throwable Failure reason.

See also:

  • \Throwable

offsetGet(mixed $offset): \Amp\Promise

Get data at an array offset asynchronously.

Parameters:

  • $offset: mixed Offset

See also:

  • \Amp\Promise

getTrace(): array

Get current stack trace for running coroutine.

getFrame(): array

Get current execution frame.

jsonSerialize(): string

Obtain.

onResolve()


Generated by danog/phpdoc