Skip to content

Commit

Permalink
Merge pull request #78 from clue-labs/delay-docs-v4
Browse files Browse the repository at this point in the history
Minor documentation improvements
  • Loading branch information
WyriHaximus authored Jun 19, 2023
2 parents 5c7e785 + b64af2c commit ecd5cef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ $promise->then(function (int $bytes) {
});
```

## delay()
### delay()

The `delay(float $seconds): void` function can be used to
delay program execution for duration given in `$seconds`.
Expand Down Expand Up @@ -421,7 +421,7 @@ same loop until the delay returns:

```php
echo 'a';
Loop::addTimer(1.0, function () {
Loop::addTimer(1.0, function (): void {
echo 'b';
});
React\Async\delay(3.0);
Expand Down Expand Up @@ -453,13 +453,13 @@ Everything inside this function will still be blocked, but everything outside
this function can be executed asynchronously without blocking:

```php
Loop::addTimer(0.5, React\Async\async(function () {
Loop::addTimer(0.5, React\Async\async(function (): void {
echo 'a';
React\Async\delay(1.0);
echo 'c';
}));

Loop::addTimer(1.0, function () {
Loop::addTimer(1.0, function (): void {
echo 'b';
});

Expand All @@ -481,13 +481,13 @@ promise will clean up any pending timers and throw a `RuntimeException` from
the pending delay which in turn would reject the resulting promise.

```php
$promise = async(function () {
$promise = async(function (): void {
echo 'a';
delay(3.0);
echo 'b';
});
})();

Loop::addTimer(2.0, function () use ($promise) {
Loop::addTimer(2.0, function () use ($promise): void {
$promise->cancel();
});

Expand Down
12 changes: 6 additions & 6 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
*
* ```php
* echo 'a';
* Loop::addTimer(1.0, function () {
* Loop::addTimer(1.0, function (): void {
* echo 'b';
* });
* React\Async\delay(3.0);
Expand Down Expand Up @@ -416,13 +416,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
* this function can be executed asynchronously without blocking:
*
* ```php
* Loop::addTimer(0.5, React\Async\async(function () {
* Loop::addTimer(0.5, React\Async\async(function (): void {
* echo 'a';
* React\Async\delay(1.0);
* echo 'c';
* }));
*
* Loop::addTimer(1.0, function () {
* Loop::addTimer(1.0, function (): void {
* echo 'b';
* });
*
Expand All @@ -444,13 +444,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
* the pending delay which in turn would reject the resulting promise.
*
* ```php
* $promise = async(function () {
* $promise = async(function (): void {
* echo 'a';
* delay(3.0);
* echo 'b';
* });
* })();
*
* Loop::addTimer(2.0, function () use ($promise) {
* Loop::addTimer(2.0, function () use ($promise): void {
* $promise->cancel();
* });
*
Expand Down

0 comments on commit ecd5cef

Please sign in to comment.