[RxJS] Completing a Stream with TakeWhile
Subscribe can take three params:
subscribe(
(x)=> console.log(x),
err=> console.log(err),
()=> console.log('complete')
);
If we want to stop the progame at some condition, so we need to notify complete function, which is the third param in subscribe.
Observable.combineLatest(
timer$,
input$,
(timer, input)=> ({count: timer.count, text: input})
)
.takeWhile((data)=> data.count <= )
.filter((data)=> data.count === parseInt(data.text))
.subscribe(
(x)=> console.log(x),
err=> console.log(err),
()=> console.log('complete')
);
We can use takeWhile() function to end the program, so after the count = 3, "complete" will logout
[RxJS] Completing a Stream with TakeWhile的更多相关文章
- [RxJS] Toggle A Stream On And Off With RxJS
This lesson covers how to toggle an observable on and off from another observable by showing how to ...
- [RxJS] Logging a Stream with do()
To help understand your stream, you’ll almost always want to log out some the intermediate values to ...
- [RxJS] Stopping a Stream with TakeUntil
Observables often need to be stopped before they are completed. This lesson shows how to use takeUnt ...
- [RxJS] Starting a Stream with SwitchMap & switchMapTo
From an event map to another event we can use switchMap(), switchMap() accept an function which retu ...
- angular7 Rxjs 异步请求
Promise 和 RxJS 处理异步对比 Promise 处理异步: let promise = new Promise(resolve => { setTimeout(() => { ...
- RxJS v6 学习指南
为什么要使用 RxJS RxJS 是一套处理异步编程的 API,那么我将从异步讲起. 前端编程中的异步有:事件(event).AJAX.动画(animation).定时器(timer). 异步常见的问 ...
- 怎么break java8 stream的foreach
目录 简介 使用Spliterator 自定义forEach方法 总结 怎么break java8 stream的foreach 简介 我们通常需要在java stream中遍历处理里面的数据,其中f ...
- 5万字长文:Stream和Lambda表达式最佳实践-附PDF下载
目录 1. Streams简介 1.1 创建Stream 1.2 Streams多线程 1.3 Stream的基本操作 Matching Filtering Mapping FlatMap Reduc ...
- Java9系列第6篇-Stream流API的增强
我计划在后续的一段时间内,写一系列关于java 9的文章,虽然java 9 不像Java 8或者Java 11那样的核心java版本,但是还是有很多的特性值得关注.期待您能关注我,我将把java 9 ...
随机推荐
- Android之旅十八 百度地图环境搭建
在android中使用百度地图,我们能够先看看百度地图对应的SDK信息:http://developer.baidu.com/map/index.php? title=androidsdk,它里面基本 ...
- JQuery动态增加删除元素
<form action="" method="post" enctype="multipart/form-data"> < ...
- arraylist的使用
ArraylistDemo package cn.stat.p6.arraylist.demo; import java.util.ArrayList; import java.util.Iterat ...
- ZOJ 1642
题意:有两个字符串,每个串由n个字符组成,每个字符有一个价值,Roy每次指定串2中的一个字符,他的得分增加的值为这个字符的价值,然后把两个串中这个字符前面的那部分(包括这个字符)删掉,重复进行这样的操 ...
- iOS中的UIWindow
UIWindow的作用 UIWindow主要有两个作用: 1 作为UIView视图的最顶层容器,包含所有要显示的UIView 2 传递触摸,非触摸,键盘事件,其中传递非触摸和键盘事件时,UIWindo ...
- 一个简单的redis调用类
能只能判断函数的调用规则,容错规则, 例如set函数 set($key, $value, $time = false) 根据time的真假来判断是否使用set,或者是setex函数 get函数 get ...
- 关于exec命令函数
exec执行某命令在命令行下没有问题,但是在php中就出错.这个问题99.99%与权限有关,但是exec执行的命令不会返回错误.一个技巧就是使用管道命令,假设你的exec调用如下: exec('con ...
- python文件_读取
1.文件的读取和显示 方法1: f=open(r'G:\2.txt') print f.read() f.close() 方法2: try: t=open(r'G:\2.txt') print t.r ...
- pyqt5消息框QMessageBox
QMessageBox消息框有以下几种类型: QMessageBox.information 信息框 QMessageBox.question 问答框 QMessageBox.warning ...
- DataTables给表格绑定事件
$(document).ready(function() { $('#example').dataTable(); $('#example tbody').on('click', 'tr', func ...