<?php require_once __DIR__ . '/../bootstrap.php'; $observable = Rx\Observable::range(0, 5)->skipLast(3); $observable->subscribe($stdoutObserver);
<?php require_once __DIR__ . '/../bootstrap.php'; $source = Rx\Observable::range(0, 9)->average(); $subscription = $source->subscribe($stdoutObserver);
<?php require_once __DIR__ . '/../bootstrap.php'; $source = Rx\Observable::range(0, 3)->map(function ($x) { return \Rx\Observable::range($x, 3); })->concatAll(); $subscription = $source->subscribe($stdoutObserver);
<?php require_once __DIR__ . '/../bootstrap.php'; $loop = React\EventLoop\Factory::create(); $scheduler = new Rx\Scheduler\EventLoopScheduler($loop); $observable = Rx\Observable::range(1, 5); $selectManyObservable = $observable->flatMap(function ($value) { return Rx\Observable::range(1, $value); }, $scheduler); $disposable = $selectManyObservable->subscribe($stdoutObserver, $scheduler); $loop->run();
<?php require_once __DIR__ . '/../bootstrap.php'; //With a seed $source = Rx\Observable::range(1, 3); $subscription = $source->scan(function ($acc, $x) { return $acc * $x; }, 1)->subscribe($createStdoutObserver());
<?php require_once __DIR__ . '/../bootstrap.php'; $loop = \React\EventLoop\Factory::create(); $scheduler = new \Rx\Scheduler\EventLoopScheduler($loop); $obs = \Rx\Observable::interval(100, $scheduler)->take(3)->mapWithIndex(function ($i) { return $i; }); $source = Rx\Observable::range(0, 5)->concatMapTo($obs); $subscription = $source->subscribe($stdoutObserver); $loop->run();
<?php require_once __DIR__ . '/../bootstrap.php'; $observable = Rx\Observable::range(1, 5)->skipWhile(function ($x) { return $x < 3; }); $observable->subscribe($stdoutObserver);
<?php require_once __DIR__ . '/../bootstrap.php'; $loop = \React\EventLoop\Factory::create(); $scheduler = new \Rx\Scheduler\EventLoopScheduler($loop); $source = Rx\Observable::range(0, 5)->concatMap(function ($x, $i) use($scheduler) { return \Rx\Observable::interval(100, $scheduler)->take($x)->map(function () use($i) { return $i; }); }); $subscription = $source->subscribe($stdoutObserver); $loop->run();
<?php require_once __DIR__ . '/../bootstrap.php'; $loop = React\EventLoop\Factory::create(); $scheduler = new Rx\Scheduler\EventLoopScheduler($loop); $sources = Rx\Observable::range(0, 3)->map(function ($x) { return Rx\Observable::range($x, 3); }); $merged = \Rx\Observable::mergeAll($sources); $disposable = $merged->subscribe($stdoutObserver, $scheduler); $loop->run();
<?php require_once __DIR__ . '/../bootstrap.php'; $observable = Rx\Observable::range(1, 5)->skipWhileWithIndex(function ($i, $value) { return $i < 3; }); $observable->subscribe($stdoutObserver);
<?php require_once __DIR__ . '/../bootstrap.php'; $source = Rx\Observable::range(1, 10)->sum(); $subscription = $source->subscribe($stdoutObserver);
<?php require_once __DIR__ . '/../bootstrap.php'; $loop = React\EventLoop\Factory::create(); $scheduler = new Rx\Scheduler\EventLoopScheduler($loop); $observable = Rx\Observable::range(1, 5); $selectManyObservable = $observable->flatMapTo(\Rx\Observable::range(0, 2)); $disposable = $selectManyObservable->subscribe($stdoutObserver, $scheduler); $loop->run();
<?php require_once __DIR__ . '/../bootstrap.php'; $source = Rx\Observable::range(1, 6)->bufferWithCount(2, 1)->subscribe($stdoutObserver);