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


PHP Observable::emptyObservable方法代码示例

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


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

示例1: timestamp_empty

 /**
  * @test
  */
 public function timestamp_empty()
 {
     $results = $this->scheduler->startWithCreate(function () {
         return Observable::emptyObservable($this->scheduler)->timestamp($this->scheduler);
     });
     $this->assertMessages([onCompleted(201)], $results->getMessages());
 }
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:10,代码来源:TimestampTest.php

示例2: repeatWhen_Observable_complete

 /**
  * @test
  */
 public function repeatWhen_Observable_complete()
 {
     $xs = $this->createColdObservable([onNext(10, 1), onNext(20, 2), onCompleted(30)]);
     $results = $this->scheduler->startWithCreate(function () use($xs) {
         return $xs->repeatWhen(function () {
             return Observable::emptyObservable();
         });
     });
     $this->assertMessages([onNext(210, 1), onNext(220, 2), onCompleted(230)], $results->getMessages());
     $this->assertSubscriptions([subscribe(200, 230)], $xs->getSubscriptions());
 }
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:14,代码来源:RepeatWhenTest.php

示例3: __invoke

 /**
  * @param \Rx\ObservableInterface $observable
  * @param \Rx\ObserverInterface $observer
  * @param \Rx\SchedulerInterface $scheduler
  * @return \Rx\DisposableInterface
  */
 public function __invoke(ObservableInterface $observable, ObserverInterface $observer, SchedulerInterface $scheduler = null)
 {
     $buffer = "";
     return $observable->defaultIfEmpty(Observable::just(null))->concat(Observable::just($this->delimiter))->concatMap(function ($x) use(&$buffer) {
         if ($x === null || $buffer === null) {
             $buffer = null;
             return Observable::emptyObservable();
         }
         $items = explode($this->delimiter, $buffer . $x);
         $buffer = array_pop($items);
         return Observable::fromArray($items);
     })->subscribe($observer, $scheduler);
 }
开发者ID:RxPHP,项目名称:RxOperatorExtras,代码行数:19,代码来源:CutOperator.php

示例4:

<?php

require_once __DIR__ . '/../bootstrap.php';
$source1 = \Rx\Observable::just(42);
$source2 = \Rx\Observable::just(56);
$source = \Rx\Observable::emptyObservable()->concat($source1)->concat($source2);
$subscription = $source->subscribe($stdoutObserver);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:7,代码来源:concat.php

示例5:

<?php

require_once __DIR__ . '/../bootstrap.php';
$source = \Rx\Observable::emptyObservable()->defaultIfEmpty(new \Rx\Observable\ReturnObservable("something"));
$subscription = $source->subscribe($stdoutObserver);
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:5,代码来源:defaultIfEmpty.php

示例6:

<?php

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

示例7: send

 /**
  * Squirt the metrics over UDP
  *
  * @param array $data Incoming Data
  * @param float|1 $sampleRate the rate (0-1) for sampling.
  * @param array|string $tags Key Value array of Tag => Value, or single tag as string
  *
  * @return Observable
  **/
 public function send($data, $sampleRate = 1, array $tags = null)
 {
     // sampling
     $sampledData = array();
     if ($sampleRate < 1) {
         foreach ($data as $stat => $value) {
             if (mt_rand() / mt_getrandmax() <= $sampleRate) {
                 $sampledData[] = [$stat, "{$value}|@{$sampleRate}"];
             }
         }
     } else {
         foreach ($data as $stat => $value) {
             $sampledData[] = [$stat, $value];
         }
     }
     if (empty($sampledData)) {
         return Observable::emptyObservable();
     }
     $observableSequence = Observable::fromArray($sampledData)->map(function ($d) use($tags) {
         $stat = $d[0];
         $value = $d[1];
         if ($tags !== null && is_array($tags) && count($tags) > 0) {
             $value .= '|';
             foreach ($tags as $tag_key => $tag_val) {
                 if (is_array($tag_val)) {
                     $flattenTagVal = array();
                     array_walk_recursive($array, function ($a) use(&$return) {
                         $flattenTagVal[] = $a;
                     });
                     $tag_val = implode("\n", $flattenTagVal);
                 }
                 $value .= '#' . $tag_key . ':' . $tag_val . ',';
             }
             $value = substr($value, 0, -1);
         } elseif (isset($tags) && !empty($tags)) {
             $value .= '|#' . $tags;
         }
         return $this->reportMetric("{$stat}:{$value}");
     });
     return Observable::mergeAll($observableSequence);
 }
开发者ID:domraider,项目名称:rxnet,代码行数:50,代码来源:Statsd.php

示例8:

<?php

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


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