Lines
n/a
0 / 0
Functions and Methods
n/a
0 / 0
Classes and Traits
n/a
0 / 0
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts; | |
| 6 | ||
| 7 | use Closure; | |
| 8 | use Stewart\Contracts\Exception\TimeException; | |
| 9 | use Stewart\Contracts\Exception\WaitException; | |
| 10 | use Stewart\Contracts\Stream\Edge; | |
| 11 | use Stewart\Contracts\Time\Duration; | |
| 12 | ||
| 13 | /** @template-covariant T */ | |
| 14 | interface EventStream | |
| 15 | { | |
| 16 | /** @param Closure(T): void $handler */ | |
| 17 | public function subscribe(Closure $handler): Subscription; | |
| 18 | ||
| 19 | /** @param Closure(T): bool $predicate */ | |
| 20 | public function filter(Closure $predicate): static; | |
| 21 | ||
| 22 | /** | |
| 23 | * @template U | |
| 24 | * @param Closure(T): U $mapper | |
| 25 | * @return EventStream<U> | |
| 26 | */ | |
| 27 | public function map(Closure $mapper): EventStream; | |
| 28 | ||
| 29 | /** @throws TimeException */ | |
| 30 | public function debounce(Duration $window, Edge $edge = Edge::Trailing): static; | |
| 31 | ||
| 32 | /** @throws TimeException */ | |
| 33 | public function throttle(Duration $window, Edge $edge = Edge::Leading): static; | |
| 34 | ||
| 35 | public function take(int $count): static; | |
| 36 | ||
| 37 | /** @param EventStream<mixed> $notifier */ | |
| 38 | public function takeUntil(EventStream $notifier): static; | |
| 39 | ||
| 40 | // Returns null once the timeout passes; without one it waits until an event arrives or the stream completes. | |
| 41 | /** | |
| 42 | * @return T|null | |
| 43 | * @throws WaitException | |
| 44 | */ | |
| 45 | public function waitForNext(?Duration $timeout = null): mixed; | |
| 46 | } |