mirror of
https://github.com/danog/byte-stream.git
synced 2024-11-30 04:19:23 +01:00
Use a Producer in the IteratorStream docs
This commit is contained in:
parent
75b2f2098c
commit
2049e76771
@ -3,16 +3,10 @@
|
||||
`IteratorStream` allows converting an `Amp\Iterator` that yields strings into an `InputStream`.
|
||||
|
||||
```php
|
||||
$emitter = new Emitter;
|
||||
|
||||
asyncCoroutine(function () use ($emitter) {
|
||||
$inputStream = new IteratorStream(new Producer(function (callable $emit) {
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
yield new Delayed(1000);
|
||||
yield $emitter->emit(".");
|
||||
yield $emit(".");
|
||||
}
|
||||
|
||||
$emitter->complete();
|
||||
});
|
||||
|
||||
$inputStream = new IteratorStream($emitter->iterate());
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user