From a096a36f9a796e6a76a500d142a09ae4cbe22546 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Wed, 26 Apr 2017 13:14:10 -0500 Subject: [PATCH] =?UTF-8?q?Emitter::resolve=20=E2=86=92=20Emitter::complet?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Emitter.php | 20 +++++++++----------- lib/functions.php | 6 +++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/Emitter.php b/lib/Emitter.php index 374a6b5..19af4d8 100644 --- a/lib/Emitter.php +++ b/lib/Emitter.php @@ -7,8 +7,8 @@ try { if (!@\assert(false)) { development: // PHP 7 development (zend.assertions=1) /** - * Deferred is a container for a stream that can emit values using the emit() method and resolved using the - * resolve() and fail() methods of this object. The contained stream may be accessed using the stream() method. + * Deferred is a container for a stream that can emit values using the emit() method and completed using the + * complete() and fail() methods of this object. The contained stream may be accessed using the stream() method. * This object should not be part of a public API, but used internally to create and emit values from a stream. */ final class Emitter { @@ -25,7 +25,7 @@ try { /** * @var callable */ - private $resolve; + private $complete; /** * @var callable @@ -34,9 +34,9 @@ try { public function __construct() { $this->stream = new Internal\PrivateStream( - function (callable $emit, callable $resolve, callable $fail) { + function (callable $emit, callable $complete, callable $fail) { $this->emit = $emit; - $this->resolve = $resolve; + $this->complete = $complete; $this->fail = $fail; } ); @@ -61,12 +61,10 @@ try { } /** - * Resolves the stream with the given value. - * - * @param mixed $value + * Completes the stream. */ - public function resolve($value = null) { - ($this->resolve)($value); + public function complete() { + ($this->complete)(); } /** @@ -86,7 +84,7 @@ try { */ eval('namespace Amp; final class Emitter implements Stream { - use Internal\Producer { emit as public; resolve as public; fail as public; } + use Internal\Producer { emit as public; complete as public; fail as public; } public function stream(): Stream { return $this; } }'); } diff --git a/lib/functions.php b/lib/functions.php index 3cc73e6..301927a 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -579,7 +579,7 @@ namespace Amp\Stream { $emitter->fail($exception); $emitter = null; } else { - $emitter->resolve(); + $emitter->complete(); } }); @@ -638,13 +638,13 @@ namespace Amp\Stream { $promise = Promise\all($previous); } - $promise->onResolve(function ($exception, array $values = null) use ($emitter) { + $promise->onResolve(function ($exception) use ($emitter) { if ($exception) { $emitter->fail($exception); return; } - $emitter->resolve($values); + $emitter->complete(); }); return $emitter->stream();