Skip to content

Latest commit

 

History

History
15 lines (9 loc) · 1.01 KB

README.md

File metadata and controls

15 lines (9 loc) · 1.01 KB

Serialized Promises demo

This is a quick demo / proof of concept combining promises (React/Promise) with serializing (using Opis/Closure) - allowing us to create promises that resolve in a later PHP thread.

To make this work correctly, after composer install you need to maunually apply reactphp/promise#179 to vendor/react/promise/src/Promise.php.

Basic premise is a greeter class. When someone arrives we greet them, assign them an id & create a promise can be resolved when they leave - farewelling them by name.

For this to work the promise must not only successfully serialise its resolve closure, it must also retain/restore the $this instance being called within the then callback when the promise is resolved. If this fails it will not know the name to farewell.

Usage

  1. Ensure guests is writable.
  2. Run index.php. This will create a promise & give you instructions on resolving the promise.
  3. Run the command provided in step 2 - something like php resolve.php <id>