reactphp / promise

Promises/A implementation for PHP.
https://reactphp.org/promise/
MIT License
2.38k stars 146 forks source link

Properly instantiate LazyPromise #121

Closed holtkamp closed 6 years ago

holtkamp commented 6 years ago

And while we are at it? Maybe a more (concrete) real life example on how to use this? Tried to understand the example and tried to use it, but I find it hard to understand...

Context: I try to use lazy Promises in a Queue to reduce the amount of used / allocated memory...

jsor commented 6 years ago

@holtkamp The LazyPromise is just a wrapper around a callback which produces the "real" promise only once then() is called on the LazyPromise. Since almost in all cases, then() is called immediately, it doesn't provide a real benefit and thus we decided to remove in for v3.0 (#98).

holtkamp commented 6 years ago

@jsor thanks for the explanation!