Skip to content

Commit

Permalink
Return awaitable from defer callback
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Aug 26, 2016
1 parent 1202299 commit 6946cc1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/BodyParser.php
Expand Up @@ -55,7 +55,9 @@ public function __construct(Request $req, array $options = []) {

\Amp\defer(function() {
if ($this->parsing === true) {
new Coroutine($this->initIncremental());
$awaitable = new Coroutine($this->initIncremental());
} else {
$awaitable = null;
}
$this->body->when(function ($e, $data) {
$this->req = null;
Expand Down Expand Up @@ -88,6 +90,7 @@ public function __construct(Request $req, array $options = []) {
$this->subscribers = [];
}
});
return $awaitable;
});
}

Expand Down Expand Up @@ -279,7 +282,7 @@ private function error(\Throwable $e = null) {
$this->fail($e);
}

// this should be inside a defer (not direct Coroutine) to give user a chance to install watch() handlers
// this should be inside a defer (not direct Coroutine) to give user a chance to install subscribe() handlers
private function initIncremental() {
if ($this->parsing !== true) {
return;
Expand Down

0 comments on commit 6946cc1

Please sign in to comment.