2016-12-29 21:09:49 +01:00
|
|
|
<?php
|
2016-08-16 06:46:26 +02:00
|
|
|
|
2016-05-27 01:20:05 +02:00
|
|
|
namespace Amp\Internal;
|
|
|
|
|
2017-01-07 19:24:40 +01:00
|
|
|
use Amp\CallableMaker;
|
2017-01-04 02:10:27 +01:00
|
|
|
use Amp\Stream;
|
2016-05-27 01:20:05 +02:00
|
|
|
|
|
|
|
/**
|
2017-01-04 02:10:27 +01:00
|
|
|
* An stream that cannot externally emit values. Used by Emitter in development mode.
|
2016-06-01 18:37:12 +02:00
|
|
|
*
|
|
|
|
* @internal
|
2016-05-27 01:20:05 +02:00
|
|
|
*/
|
2017-01-04 02:10:27 +01:00
|
|
|
final class PrivateStream implements Stream {
|
2017-01-07 19:24:40 +01:00
|
|
|
use CallableMaker, Producer;
|
2016-05-27 01:20:05 +02:00
|
|
|
|
|
|
|
/**
|
2017-01-04 02:10:27 +01:00
|
|
|
* @param callable(callable $emit, callable $complete, callable $fail): void $producer
|
2016-05-27 01:20:05 +02:00
|
|
|
*/
|
2017-01-04 02:10:27 +01:00
|
|
|
public function __construct(callable $producer) {
|
2017-01-07 19:24:40 +01:00
|
|
|
$producer(
|
|
|
|
$this->callableFromInstanceMethod("emit"),
|
|
|
|
$this->callableFromInstanceMethod("resolve"),
|
|
|
|
$this->callableFromInstanceMethod("fail")
|
|
|
|
);
|
2016-05-27 01:20:05 +02:00
|
|
|
}
|
|
|
|
}
|