mirror of
https://github.com/danog/amp.git
synced 2025-01-21 21:01:16 +01:00
Return promise/result from bound functions
This commit is contained in:
parent
ec7b77d156
commit
934d1aeffb
@ -200,9 +200,9 @@ trait GeneratorResolver {
|
||||
if (is_callable($current)) {
|
||||
$promise = new Success(function() use ($current) {
|
||||
$result = call_user_func_array($current, func_get_args());
|
||||
if ($result instanceof \Generator) {
|
||||
$this->resolveGenerator($result);
|
||||
}
|
||||
return $result instanceof \Generator
|
||||
? $this->resolveGenerator($result)
|
||||
: $result;
|
||||
});
|
||||
} else {
|
||||
$promise = new Failure(new \DomainException(
|
||||
|
@ -298,7 +298,8 @@ class GeneratorResolverTest extends \PHPUnit_Framework_TestCase {
|
||||
// Because this Generator function is bound to the reactor it should be
|
||||
// automatically resolved and our repeating watcher should be cancelled
|
||||
// allowing the reactor to stop running.
|
||||
$boundFunc();
|
||||
$result = $boundFunc();
|
||||
$this->assertInstanceOf('Amp\\Promise', $result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user