basic async-interop support; generator consumer missing
[m6w6/seekat] / lib / API / Future.php
diff --git a/lib/API/Future.php b/lib/API/Future.php
new file mode 100644 (file)
index 0000000..8c3571c
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace seekat\API;
+
+use AsyncInterop\Promise;
+
+interface Future
+{
+       /**
+        * @param callable $onCancel
+        * @return mixed Promisor providing a promise() method
+        */
+       function createContext(callable $onCancel = null);
+
+       /**
+        * @param object $context Promisor
+        * @return Promise
+        */
+       function getPromise($context) : Promise;
+
+       /**
+        * @param object $context Promisor returned by createContext
+        * @param mixed $value
+        * @return void
+        */
+       function onSuccess($context, $value);
+
+       /**
+        * @param object $context Proisor returned by createContext
+        * @param mixed $reason
+        * @return void
+        */
+       function onFailure($context, $reason);
+
+       /**
+        * @param object $context Promisor returned by createContext
+        * @param mixed $update
+        * @return void
+        */
+       function onUpdate($context, $update);
+}