Skip to content

Commit 177fe31

Browse files
authored
Merge pull request #98 from jsor-labs/remove-lazy-promise
[RFC] Remove LazyPromise
2 parents 3675021 + 35c8e09 commit 177fe31

4 files changed

Lines changed: 1 addition & 192 deletions

File tree

README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Table of Contents
3232
* [Promise](#promise-2)
3333
* [FulfilledPromise](#fulfilledpromise)
3434
* [RejectedPromise](#rejectedpromise)
35-
* [LazyPromise](#lazypromise)
3635
* [Functions](#functions)
3736
* [resolve()](#resolve)
3837
* [reject()](#reject)
@@ -156,7 +155,6 @@ Neither its state nor its result (or error) can be modified.
156155
* [Promise](#promise-2)
157156
* [FulfilledPromise](#fulfilledpromise)
158157
* [RejectedPromise](#rejectedpromise)
159-
* [LazyPromise](#lazypromise)
160158

161159
#### PromiseInterface::then()
162160

@@ -361,27 +359,6 @@ $promise = React\Promise\RejectedPromise($reason);
361359
Note, that `$reason` **cannot** be a promise. It's recommended to use
362360
[reject()](#reject) for creating rejected promises.
363361

364-
### LazyPromise
365-
366-
Creates a promise which will be lazily initialized by `$factory` once a consumer
367-
calls the `then()` method.
368-
369-
```php
370-
$factory = function () {
371-
$deferred = new React\Promise\Deferred();
372-
373-
// Do some heavy stuff here and resolve the deferred once completed
374-
375-
return $deferred->promise();
376-
};
377-
378-
$promise = new React\Promise\LazyPromise($factory);
379-
380-
// $factory will only be executed once we call then()
381-
$promise->then(function ($value) {
382-
});
383-
```
384-
385362
### Functions
386363

387364
Useful functions for creating, joining, mapping and reducing collections of

src/LazyPromise.php

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/Promise.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,8 @@ private function settle(PromiseInterface $result)
132132

133133
private function unwrap($promise)
134134
{
135-
$promise = $this->extract($promise);
136-
137135
while ($promise instanceof self && null !== $promise->result) {
138-
$promise = $this->extract($promise->result);
139-
}
140-
141-
return $promise;
142-
}
143-
144-
private function extract($promise)
145-
{
146-
if ($promise instanceof LazyPromise) {
147-
$promise = $promise->promise();
136+
$promise = $promise->result;
148137
}
149138

150139
if ($promise === $this) {

tests/LazyPromiseTest.php

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)