Single, race both get only one emit value from the stream.

Single(fn):

const source = Rx.Observable.from([1,2,3,4,5]);
var single = source.single( x => x === 3); /* (12345)| (source) single( x => x === 3)
3| (single) */ var sub = single.subscribe( x => console.log(x)); //

race(...observable): Observable

const winner = Rx.Observable.race(
//emit every 1.5s
Rx.Observable.interval(1500),
//emit every 1s
Rx.Observable.interval(1000).mapTo('1s won!'),
//emit every 2s
Rx.Observable.interval(2000),
//emit every 2.5s
Rx.Observable.interval(2500)
).take(1); /** ------0 (1500)
----0 (1000).mapTo('1s won!')
--------0 (2000)
----------0 (2500) race ----(1s won!)| (take(1)) */ const sub2 = winner.subscribe( x => console.log(x)); // 1s won!

[RxJS] Filtering operator: single, race的更多相关文章

  1. [RxJS] Filtering operator: filter

    This lesson introduces filter: an operator that allows us to let only certain events pass, while ign ...

  2. [RxJS] Filtering operators: distinct and distinctUntilChanged

    Operator distinct() and its variants are an important type of Filtering operator. This lessons shows ...

  3. rxjs自定义operator

    rxjs自定义operator

  4. [RxJS] Utility operator: do

    We just saw map which is a transformation operator. There are a couple of categories of operators, s ...

  5. [RxJS] Creation operator: of()

    RxJS is a lot about the so-called "operators". We will learn most of the important operato ...

  6. [RxJS] Connection operator: multicast and connect

    We have seen how Subjects are useful for sharing an execution of an RxJS observable to multiple obse ...

  7. [rxjs] Shares a single subscription -- publish()

    If have an observable and you subscribe it twice, those tow subscritions have no connection. console ...

  8. [RxJS] Transformation operator: repeat

    Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...

  9. [RxJS] Filtering operators: throttle and throttleTime

    Debounce is known to be a rate-limiting operator, but it's not the only one. This lessons introduces ...

随机推荐

  1. compser 执行命令提示do not run composer as root/super !

    这个是因为composer为了防止非法脚本在root下执行,解决办法随便切换到非root用户即可

  2. 【python】dir(__builtins__)查看python中所用BIF(内置函数)

    dir(__builtins__)查看python中所用BIF(内置函数)

  3. Day20 Django之Model多对多、中间件、缓存、信号和分页

    一.Form补充 class IndexForm(forms.Form): # c = [ # (1, 'CEO'), # (2, 'CTO') # ] # 静态字段,属于IndexForm类,即使数 ...

  4. Warning File `.depend' has modification time 1.6 s in the future

    一.前提知识 主机时间与虚拟机时间不同步所致.我们在某一操作系统所属磁盘空间下创建一个文件,那么这个文件的创建时间是以磁盘所属的操作系统的时钟为基准的. 我们假设主机windows的系统时间是10:0 ...

  5. 上传XML文件字符编码问题

    1.上传的XML文件的空格的字符编码和倒入到数据库的空格的字符编码不是一种编码格式,导致导入到数据库的数据和XML文件的数据不一致的情况,进而使展示到界面上的数据在进行搜索时不能搜索出来.解决办法: ...

  6. 【产品体验】ONE一个

    第二篇博客,加油加油~~本人产品新人,学习中,希望大家多多指教!  先来两张ONE的界面图镇楼——        ONE简介: “复杂世界里,一个就够了.”这是一款轻量级的文艺阅读应用,每日更新一张图 ...

  7. Tomcat架构(二)

    5.容器组件 这一小节中我们将讨论请求处理组件:引擎(engine).虚拟主机.上下文(context)组件. 5.1.引擎(engine) 引擎表示可运行的Catalina的servlet引擎实例并 ...

  8. SQL server语句测试

    设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一~表(四)所示,数据如表1-2的表( ...

  9. 经典的单例模式c3p0来控制数据库连接池

    package com.c3p0.datapools; //数据库连接池  单例模式 import java.sql.Connection; import java.sql.SQLException; ...

  10. mysql 海量数据的存储和访问解决方案

    第1章  引言 随着互联网应用的广泛普及,海量数据的存储和访问成为了系统设计的瓶颈问题.对于一个大型的互 联网应用,每天几十亿的PV无疑对数据库造成了相当高的负载.对于系统的稳定性和扩展性造成了极大的 ...