PHPackages                             wyrihaximus/react-awaitable-observable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wyrihaximus/react-awaitable-observable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wyrihaximus/react-awaitable-observable
======================================

🛠️ Make observables foreachable using async &amp;amp; await

1.2.1(2mo ago)5382.3k[1 issues](https://github.com/WyriHaximus/reactphp-awaitable-observable/issues)[1 PRs](https://github.com/WyriHaximus/reactphp-awaitable-observable/pulls)2MITMakefilePHP ^8.4CI passing

Since Jan 27Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/WyriHaximus/reactphp-awaitable-observable)[ Packagist](https://packagist.org/packages/wyrihaximus/react-awaitable-observable)[ GitHub Sponsors](https://github.com/WyriHaximus)[ RSS](/packages/wyrihaximus-react-awaitable-observable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (10)Versions (11)Used By (2)

[ReactPHP](https://github.com/reactphp/) awaitable observable
=============================================================

[](#reactphp-awaitable-observable)

[![Continuous Integration](https://github.com/wyrihaximus/reactphp-awaitable-observable/workflows/Continuous%20Integration/badge.svg)](https://github.com/wyrihaximus/reactphp-awaitable-observable/workflows/Continuous%20Integration/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/7aa017803caf6ce5920b514d8450343cab071d26fe142e51b81f654098ad32c9/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f72656163742d617761697461626c652d6f627365727661626c652f762f737461626c652e706e67)](https://packagist.org/packages/wyrihaximus/react-awaitable-observable)[![Total Downloads](https://camo.githubusercontent.com/006c74dfdfb7378b8fe28f400c8f9af035e46a497d84acac59e4654f294e77a5/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f72656163742d617761697461626c652d6f627365727661626c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/wyrihaximus/react-awaitable-observable/stats)[![Type Coverage](https://camo.githubusercontent.com/734b165994587a21325a7f51bbe413e832e8e90c3993b2a528634209603b1ea4/68747470733a2f2f73686570686572642e6465762f6769746875622f57797269486178696d75732f72656163747068702d617761697461626c652d6f627365727661626c652f636f7665726167652e737667)](https://shepherd.dev/github/WyriHaximus/reactphp-awaitable-observable)[![License](https://camo.githubusercontent.com/98fe902986a6d631270ed471befb37e5576becdd3334fb81a83220e6984da132/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f72656163742d617761697461626c652d6f627365727661626c652f6c6963656e73652e706e67)](https://packagist.org/packages/wyrihaximus/react-awaitable-observable)

### Installation

[](#installation)

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.

```
composer require wyrihaximus/react-awaitable-observable

```

Usage
-----

[](#usage)

The `awaitObservable` function will accept any observable and turn it into an iterator, so it can be used inside `async` in an `foreach`:

```
use Rx\Observable;
use Rx\Scheduler\ImmediateScheduler;

use function React\Async\async;
use function WyriHaximus\React\awaitObservable;

async(function () {
    $observable = Observable::fromArray(range(0, 1337), new ImmediateScheduler());

    foreach (awaitObservable($observable) as $integer) {
        echo $integer; // outputs 01234....13361337
    }
});
```

Breaking the iterator
---------------------

[](#breaking-the-iterator)

The example above assumes you won't break the iterator. There are however situations where you want to short circuit the iterator, for such situations the `break` method is provided.

```
use Rx\Observable;
use Rx\Scheduler\ImmediateScheduler;

use function React\Async\async;
use function WyriHaximus\React\awaitObservable;

async(function () {
    $observable = Observable::fromArray(range(0, 1337), new ImmediateScheduler());

    $iterator = awaitObservable($observable);
    foreach ($iterator as $integer) {
        echo $integer; // outputs 01234
        if ($integer >= 4) {
            $iterator->break();
        }
    }
});
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

Copyright 2022 [Cees-Jan Kiewiet](https://wyrihaximus.net/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 75.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~432 days

Total

4

Last Release

79d ago

PHP version history (3 changes)1.0.0PHP ^8.1

1.1.0PHP ^8.2

1.2.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (83 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (25 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (1 commits)")[![renovate-runner[bot]](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/renovate-runner[bot] "renovate-runner[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/wyrihaximus-react-awaitable-observable/health.svg)

```
[![Health](https://phpackages.com/badges/wyrihaximus-react-awaitable-observable/health.svg)](https://phpackages.com/packages/wyrihaximus-react-awaitable-observable)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[react/react

ReactPHP: Event-driven, non-blocking I/O with PHP.

9.1k3.6M63](/packages/react-react)[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[reactivex/rxphp

Reactive extensions for php.

1.7k3.2M49](/packages/reactivex-rxphp)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k379.4k24](/packages/team-reflex-discord-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
