[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 ...
随机推荐
- linux shell 切换到ROOT用户
#!/bin/bash expect -c " set timeout 1000 spawn /bin/su - root expect \&qu ...
- BitmapFactory 加载图片到内存
Bitmap占用内存分析 Android的虚拟机是基于寄存器的Dalvik,它的最大堆(单个进程可用内存)大小一般是16M,当然不同设备是不一样的,可以查看/system/build.prop文件,[ ...
- ORA-01810格式代码出现两次 的解决方案
今早做一个查询页面时,需要查询两个时间区间的跨度,使用TO_DATE函数,一开始写成了Sql代码 TO_DATE('2014-08-04 00:00:00','YYYY-MM-DD HH:mm:ss' ...
- Fling!
算法:深搜 很不错的一道题!!! Fling is a kind of puzzle games available on phone. This game is played on a board ...
- (转)yum 和 apt-get 用法及区别
原地址:http://www.cnblogs.com/adforce/archive/2013/04/12/3017577.html 一般来说著名的linux系统基本上分两大类: 1 RedHat系 ...
- sql解释执行顺序
一.查询的逻辑执行顺序 (1) FROM left_table (3) join_type JOIN right_table (2) ON join_condition (4) WHERE where ...
- 对mysql进行分表
1. 有某个自段进行md5散列,然后生成ord SCII码 $num = ord(md5($user)) //是一个数字 参考 $num/3 ,$num/4;如果我们不是严格意义上的分表,可以参考分布 ...
- transition Css3过度详解
过度语法: .example { transition-property: background-color; //需要过度的css属性 transition-duration: 2s; //过度所需 ...
- input 不支持HTML5的placeholder属性
解决方法如下: <input type="text" value="搜索乐高资讯" onfocus="if(this.value=='搜索乐高资 ...
- 整型(int)转时间格式字符串及页面long型转时间格式字符串
1,如果是封装的整型的话需要在后台进行处理再返回页面 处理过程是这样的 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm ...