[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 ...
随机推荐
- wpf-DataTemplate应用
在WPF中,决定数据外观的是DataTemplate,即DataTemplate是数据内容的表现形式,一条数据显示成什么样子,是简单的文本还是直观的图形,就是由DataTemplate决定的.下面通过 ...
- C#,.net获取字符串中指定字符串的个数、所在位置与替换字符串
方法一: public static int indexOf (字符串/字符,int从第几位开始,int共查几位) string tests = "1absjjkcbfka2rsbcfak2 ...
- Android Activity 分类
在安卓系统中,Activity 按照优先级可以分为三种: 1. 前台Activity,是指正在和用户进行交互的Activity,优先级最高: 2.可见但非前台Activity,是指可见但无法与用户进行 ...
- arcgis server manager - An error has occured on the server. For details please check the Event (Application) log on the web.
当登陆 Arcgis Server Manager的时候,点击 "Services" 中的选项"Manage Services",就报错: An error h ...
- iOS基础框架的搭建 / 及国际化操作
1.基础框架的搭建 1.1 pod引入常用的第三方类库 1.2 创建基础文件夹结构/目录结构 Resource———存放声音/图片/xib/storyboard 等资源文件 Define——宏定义, ...
- ios9基础知识总结(foundation)笔记
类:NSObject .NSString.NSMutableString.NSNumber.NSValue.NSDate.NSDateFormatter.NSRange.Collections:NSS ...
- self和super之间的区别
关于 self 和 super 之间的区别, 首先要了解 1, self 是什么 :super 是什么.2,[ super init] 做什么.3,为什么要 self = [super init ...
- [C#] 常用函数
查找字符串: string test="a,b,c,de"; 方法1:Contains test.Contains("b") //返回值 true 方法2:E ...
- [FileStream] 使用
// 要上传的文件 FileStream fs = new FileStream(路径, FileMode.Open, FileAccess.Read); FileMode 是指确定如何打开或创建文件 ...
- Visual Studio的广告剧
一个热衷于code的developer,一个热衷于developer的girl,他们将发生怎样的故事? 第一集:<想做你的Code> 第二集:<让爱延长> 第三集:<幸福 ...