Skip to content

Commit

Permalink
Remove race()
Browse files Browse the repository at this point in the history
Closes #57
  • Loading branch information
jsor committed Jan 8, 2017
1 parent 3f3156d commit 7a797a5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 186 deletions.
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Table of Contents
* [resolve()](#resolve)
* [reject()](#reject)
* [all()](#all)
* [race()](#race)
* [any()](#any)
* [some()](#some)
* [map()](#map)
Expand Down Expand Up @@ -387,8 +386,8 @@ $promise->then(function ($value) {
Useful functions for creating, joining, mapping and reducing collections of
promises.

All functions working on promise collections (like `all()`, `race()`, `some()`
etc.) support cancellation. This means, if you call `cancel()` on the returned
All functions working on promise collections (like `all()`, `some()` etc.)
support cancellation. This means, if you call `cancel()` on the returned
promise, all promises in the collection are cancelled.

#### resolve()
Expand Down Expand Up @@ -436,15 +435,6 @@ Returns a promise that will resolve only once all the items in
will be an array containing the resolution values of each of the items in
`$promisesOrValues`.

#### race()

```php
$promise = React\Promise\race(array $promisesOrValues);
```

Initiates a competitive race that allows one winner. Returns a promise which is
resolved in the same way the first settled promise resolves.

#### any()

```php
Expand Down
18 changes: 0 additions & 18 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,6 @@ function all(array $promisesOrValues)
});
}

function race(array $promisesOrValues)
{
if (!$promisesOrValues) {
return resolve();
}

$cancellationQueue = new CancellationQueue();

return new Promise(function ($resolve, $reject) use ($promisesOrValues, $cancellationQueue) {
foreach ($promisesOrValues as $promiseOrValue) {
$cancellationQueue->enqueue($promiseOrValue);

resolve($promiseOrValue)
->done($resolve, $reject);
}
}, $cancellationQueue);
}

function any(array $promisesOrValues)
{
return some($promisesOrValues, 1)
Expand Down
156 changes: 0 additions & 156 deletions tests/FunctionRaceTest.php

This file was deleted.

0 comments on commit 7a797a5

Please sign in to comment.