当前位置: 首页>>代码示例>>PHP>>正文


PHP Observable::range方法代码示例

本文整理汇总了PHP中Rx\Observable::range方法的典型用法代码示例。如果您正苦于以下问题:PHP Observable::range方法的具体用法?PHP Observable::range怎么用?PHP Observable::range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rx\Observable的用法示例。


在下文中一共展示了Observable::range方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: range_dispose

 /**
  * @test
  */
 public function range_dispose()
 {
     $results = $this->scheduler->startWithDispose(function () {
         return Observable::range(-10, 5, $this->scheduler);
     }, 204);
     $this->assertMessages([onNext(201, -10), onNext(202, -9), onNext(203, -8)], $results->getMessages());
 }
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:10,代码来源:RangeTest.php

示例2: __invoke

 public function __invoke(Observable $attempts)
 {
     return Observable::range(1, $this->max)->zip([$attempts], function ($i, $e) {
         if ($i >= $this->max) {
             throw $e;
         }
         return $i;
     })->flatMap(function ($i) {
         return Observable::timer(1000);
     });
 }
开发者ID:domraider,项目名称:rxnet,代码行数:11,代码来源:RetryWithDelay.php

示例3: list

<?php

require_once __DIR__ . '/../bootstrap.php';
list($evens, $odds) = \Rx\Observable::range(0, 10)->partition(function ($x) {
    return $x % 2 === 0;
});
$evens->subscribe($createStdoutObserver('Evens '));
$odds->subscribe($createStdoutObserver('Odds '));
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:8,代码来源:partition.php

示例4:

<?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);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:7,代码来源:concatAll.php

示例5:

<?php

require_once __DIR__ . '/../bootstrap.php';
/* With publish */
$interval = \Rx\Observable::range(0, 10);
$source = $interval->take(2)->doOnNext(function ($x) {
    echo "Side effect\n";
});
$published = $source->publish();
$published->subscribe($createStdoutObserver('SourceC '));
$published->subscribe($createStdoutObserver('SourceD '));
$published->connect();
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:12,代码来源:publish.php

示例6:

<?php

require_once __DIR__ . '/../bootstrap.php';
$source = \Rx\Observable::range(1, 5)->takeWhile(function ($x) {
    return $x < 3;
});
$subscription = $source->subscribe($stdoutObserver);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:7,代码来源:takeWhile.php

示例7:

<?php

require_once __DIR__ . '/../bootstrap.php';
$observable = \Rx\Observable::range(0, 3);
$observable->subscribe($stdoutObserver);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:5,代码来源:range.php

示例8:

<?php

require_once __DIR__ . '/../bootstrap.php';
$source = \Rx\Observable::range(0, 5)->takeLast(3);
$source->subscribe($stdoutObserver);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:5,代码来源:takeLast.php

示例9:

<?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();
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:9,代码来源:flatMapTo.php

示例10:

<?php

require_once __DIR__ . '/../bootstrap.php';
$source = \Rx\Observable::range(1, 3)->repeat(3);
$subscription = $source->subscribe($createStdoutObserver());
//Next value: 1
//Next value: 2
//Next value: 3
//Next value: 1
//Next value: 2
//Next value: 3
//Next value: 1
//Next value: 2
//Next value: 3
//Complete!
开发者ID:xsilen,项目名称:RxPHP,代码行数:15,代码来源:repeat.php

示例11:

<?php

require_once __DIR__ . '/../bootstrap.php';
$source = \Rx\Observable::range(0, 3)->doOnNext(function ($x) {
    echo 'Do Next:', $x, PHP_EOL;
});
$subscription = $source->subscribe($stdoutObserver);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:7,代码来源:doOnNext.php

示例12:

<?php

require_once __DIR__ . '/../bootstrap.php';
$loop = \React\EventLoop\Factory::create();
$scheduler = new \Rx\Scheduler\EventLoopScheduler($loop);
$source = \Rx\Observable::range(1, 3)->flatMapLatest(function ($x) {
    return \Rx\Observable::fromArray([$x . 'a', $x . 'b']);
});
$source->subscribe($stdoutObserver, $scheduler);
$loop->run();
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:10,代码来源:flatMapLatest.php

示例13:

<?php

include __DIR__ . "/../../vendor/autoload.php";
$toFile = new \Rx\React\ToFileObserver(__DIR__ . "/../test2.csv");
\Rx\Observable::range(1, 20)->take(5)->mapTo("This is pretty cool \n")->subscribe($toFile);
开发者ID:RxPHP,项目名称:RxStream,代码行数:5,代码来源:toFile.php

示例14: function

<?php

require_once __DIR__ . '/../bootstrap.php';
$source = \Rx\Observable::range(0, 3)->doOnEach(new \Rx\Observer\CallbackObserver(function ($x) {
    echo 'Do Next:', $x, PHP_EOL;
}, function (Exception $err) {
    echo 'Do Error:', $err->getMessage(), PHP_EOL;
}, function () {
    echo 'Do Completed', PHP_EOL;
}));
$subscription = $source->subscribe($stdoutObserver);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:11,代码来源:doOnEach.php

示例15: testWithImmediateSchedulerWithRecursion

 public function testWithImmediateSchedulerWithRecursion()
 {
     $completed = false;
     $emitted = null;
     Observable::range(0, 10)->flatMap(function ($x) use(&$count) {
         if (++$count < 2) {
             return Observable::error(new \Exception("Something"));
         }
         return Observable::just(42);
     })->retry(3)->take(1)->subscribe(new CallbackObserver(function ($x) use(&$emitted) {
         $emitted = $x;
     }, null, function () use(&$completed) {
         $completed = true;
     }), new ImmediateScheduler());
     $this->assertTrue($completed);
     $this->assertEquals(42, $emitted);
 }
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:17,代码来源:RetryTest.php


注:本文中的Rx\Observable::range方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。