mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
Use Closure::fromCallable() in 7.1
This commit is contained in:
parent
aa7b76e842
commit
658edf33f7
@ -11,14 +11,13 @@ final class Emitter implements Observable {
|
|||||||
public function __construct(callable $emitter) {
|
public function __construct(callable $emitter) {
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
/**
|
if (PHP_VERSION_ID >= 70100) {
|
||||||
* @param mixed $value
|
$emit = \Closure::fromCallable([$this, 'emit']);
|
||||||
*
|
} else {
|
||||||
* @return \Interop\Async\Awaitable
|
$emit = function ($value) {
|
||||||
*/
|
return $this->emit($value);
|
||||||
$emit = function ($value) {
|
};
|
||||||
return $this->emit($value);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
$result = $emitter($emit);
|
$result = $emitter($emit);
|
||||||
|
|
||||||
|
@ -50,9 +50,14 @@ trait Producer {
|
|||||||
*/
|
*/
|
||||||
private function init() {
|
private function init() {
|
||||||
$this->waiting = new Future;
|
$this->waiting = new Future;
|
||||||
$this->unsubscribe = function ($id) {
|
|
||||||
$this->unsubscribe($id);
|
if (PHP_VERSION_ID >= 70100) {
|
||||||
};
|
$this->unsubscribe = \Closure::fromCallable([$this, 'unsubscribe']);
|
||||||
|
} else {
|
||||||
|
$this->unsubscribe = function ($id) {
|
||||||
|
$this->unsubscribe($id);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user