1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00
amp/lib/Iterator.php

31 lines
1007 B
PHP
Raw Normal View History

<?php
2016-08-16 06:46:26 +02:00
2016-05-24 18:47:14 +02:00
namespace Amp;
2016-06-01 18:37:12 +02:00
/**
2017-04-27 18:18:25 +02:00
* Defines an asynchronous iterator over a set of values that is designed to be used within a coroutine.
2016-06-01 18:37:12 +02:00
*/
2018-06-18 20:00:01 +02:00
interface Iterator
{
2016-05-24 18:47:14 +02:00
/**
* Succeeds with true if an emitted value is available by calling getCurrent() or false if the iterator has
* resolved. If the iterator fails, the returned promise will fail with the same exception.
2016-05-27 01:20:05 +02:00
*
* @return \Amp\Promise<bool>
2016-05-27 22:44:01 +02:00
*
* @throws \Error If the prior promise returned from this method has not resolved.
* @throws \Throwable The exception used to fail the iterator.
2016-05-24 18:47:14 +02:00
*/
public function advance(): Promise;
/**
* Gets the last emitted value or throws an exception if the iterator has completed.
*
* @return mixed Value emitted from the iterator.
*
* @throws \Error If the iterator has resolved or advance() was not called before calling this method.
* @throws \Throwable The exception used to fail the iterator.
*/
public function getCurrent();
2016-05-24 18:47:14 +02:00
}