2017 © Pedro Peláez
 

library rxphp

Reactive extensions for php.

image

reactivex/rxphp

Reactive extensions for php.

  • Wednesday, April 18, 2018
  • by asm89
  • Repository
  • 84 Watchers
  • 1100 Stars
  • 61,424 Installations
  • PHP
  • 36 Dependents
  • 2 Suggesters
  • 99 Forks
  • 12 Open issues
  • 27 Versions
  • 20 % Grown

The README.md

RxPHP

Reactive extensions for PHP. The reactive extensions for PHP are a set of libraries to compose asynchronous and event-based programs using observable streams., (*1)

CI status Coverage Status, (*2)

Example

$source = \Rx\Observable::fromArray([1, 2, 3, 4]);

$source->subscribe(
    function ($x) {
        echo 'Next: ', $x, PHP_EOL;
    },
    function (Exception $ex) {
        echo 'Error: ', $ex->getMessage(), PHP_EOL;
    },
    function () {
        echo 'Completed', PHP_EOL;
    }
);

//Next: 1
//Next: 2
//Next: 3
//Next: 4
//Completed

Try out the demos

$ git clone https://github.com/ReactiveX/RxPHP.git
$ cd RxPHP
$ composer install
$ php demo/interval/interval.php

Have fun running the demos in /demo., (*3)

note: When running the demos, the scheduler is automatically bootstrapped. When using RxPHP within your own project, you'll need to set the default scheduler., (*4)

Installation

  1. Install an event loop. Any event loop should work, but the ReactPHP event loop is recommended.
$ composer require react/event-loop
  1. Install RxPHP using composer.
$ composer require reactivex/rxphp
  1. Write some code.
<?php

require_once __DIR__ . '/vendor/autoload.php';

use Rx\Observable;
use React\EventLoop\Factory;
use Rx\Scheduler;

$loop = Factory::create();

//You only need to set the default scheduler once
Scheduler::setDefaultFactory(function() use($loop){
    return new Scheduler\EventLoopScheduler($loop);
});

Observable::interval(1000)
    ->take(5)
    ->flatMap(function ($i) {
        return Observable::of($i + 1);
    })
    ->subscribe(function ($e) {
        echo $e, PHP_EOL;
    });

$loop->run();

Working with Promises

Some async PHP frameworks have yet to fully embrace the awesome power of observables. To help ease the transition, RxPHP has built in support for ReactPHP promises., (*5)

Mixing a promise into an observable stream:, (*6)

Observable::interval(1000)
    ->flatMap(function ($i) {
        return Observable::fromPromise(\React\Promise\resolve(42 + $i));
    })
    ->subscribe(function ($v) {
        echo $v . PHP_EOL;
    });

Converting an Observable into a promise. (This is useful for libraries that use generators and coroutines):, (*7)

$observable = Observable::interval(1000)
    ->take(10)
    ->toArray()
    ->map('json_encode');

$promise = $observable->toPromise();

Additional Information

License

RxPHP is licensed under the MIT License - see the LICENSE file for details, (*8)

The Versions

18/04 2018

dev-master

9999999-dev https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

18/04 2018

2.0.7

2.0.7.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

02/11 2017

2.0.6

2.0.6.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

19/10 2017

2.0.5

2.0.5.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

05/09 2017

2.0.4

2.0.4.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

17/08 2017

2.0.3

2.0.3.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

21/05 2017

2.0.2

2.0.2.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

21/05 2017

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

01/04 2017

2.0.1

2.0.1.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

21/03 2017

2.0.0

2.0.0.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

14/03 2017

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

14/03 2017

1.5.3

1.5.3.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

07/02 2017

1.5.2

1.5.2.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

28/12 2016

1.5.1

1.5.1.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

26/12 2016

1.5.0

1.5.0.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

23/08 2016

1.4.1

1.4.1.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

02/08 2016

1.4.0

1.4.0.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

18/05 2016

1.3.0

1.3.0.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

02/04 2016

1.2.0

1.2.0.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

07/02 2016

1.1.0

1.1.0.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

23/01 2016

0.5.0

0.5.0.0 https://github.com/asm89/Rx.PHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

extensions reactive rx

23/01 2016

1.0.0

1.0.0.0 https://github.com/ReactiveX/RxPHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

by Matt Bonneau
by David Dan

extensions reactive rx

09/11 2015

0.4.0

0.4.0.0 https://github.com/asm89/Rx.PHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

extensions reactive rx

06/08 2015

0.3.0

0.3.0.0 https://github.com/asm89/Rx.PHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

extensions reactive rx

08/04 2014

0.2.1

0.2.1.0 https://github.com/asm89/Rx.PHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

extensions reactive rx

27/08 2013

0.2.0

0.2.0.0 https://github.com/asm89/Rx.PHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

extensions reactive rx

25/06 2013

0.1.0

0.1.0.0 https://github.com/asm89/Rx.PHP

Reactive extensions for php.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

extensions reactive rx