当前位置:网站首页>Learning notes of rxjs takeuntil operator
Learning notes of rxjs takeuntil operator
2022-06-25 09:46:00 【51CTO】
TakeUntil The official documentation for this operator is :
Emit values until provided observable emits.
That is, it can be given another anchoring role Observable, When the anchor Observable emit When the value of , The original Observable Just stop firing , Get into complete operation .
Look at a practical example :
source Observable Every 1 Second time interval , Launch one from 0 The start increment interval is 1 Integer sequence of .
We constructed a timer Observable, The timeout interval is 5 second , in other words , At the fifth second , The Observable Will send a value . This timer Observable Pass in takeUntil, As a notification Observable, Five seconds later ,source Observable Will stop firing integers .
Finally, the output of the above program execution :4 Print in seconds 0~4, Then the end .

Another example :
In this case ,interval As a primitive Observable,clicks As notification Observable, The expression of the whole program is , Every 1 The second has an increment 1 Integer sequence printing , Until a click event occurs on the page , original interval Observable End .
Look at another example :
Let's analyze the logic of this example line by line :
Generate an interval 1 An even number of seconds Observable.
Accumulate the number of even numbers generated .
When the number of even numbers generated is greater than 5 when , Emission value . This Observable As takeUntil Of notification Observable Use .
- Use eventSource and eventNumberCount, adopt
withLatestFromPut two Observable Connect , Thus in map Operator in , You can print the even value and even total amount of the current emission at the same time . adopt takeUntil Pass in one only if the total number of even numbers is greater than 5 When the value is emitted Observable, The total number of even numbers can be greater than 5 after , Give Way interval Stop sending values .
The final execution effect :

边栏推荐
- How to "transform" small and micro businesses (I)?
- Wallys/MULTI-FUNCTION IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL
- Is the client that gets the scanning code wechat or Alipay
- How do dating applets make millions a year? What is the profit model?
- Voiceprint Technology (VII): the future of voiceprint Technology
- 瑞吉外卖项目(二)
- 22 mathematical modeling contest 22 contest C
- Pytorch_ Geometric (pyg) uses dataloader to report an error runtimeerror: sizes of tenants must match except in dimension 0
- CyCa children's physical etiquette Yueqing City training results assessment successfully concluded
- 在指南针上面开户好不好,安不安全?
猜你喜欢

瑞吉外卖项目(二)

Rxjs TakeUntil 操作符的学习笔记

Online notes on Mathematics for postgraduate entrance examination (8): Kego equations, eigenvalues and eigenvectors, similarity matrix, quadratic series courses

Fcpx quickly add subtitles | Final Cut Pro import fcpxml subtitle file does not match the video time? I got it in code

Etcd教程 — 第四章 Etcd集群安全配置
![[buuctf.reverse] 117-120](/img/6c/8a90fff2bd46f1494a9bd9c77eeafc.png)
[buuctf.reverse] 117-120
![[design completion - opening report] zufeinfo 2018 software engineering major (including FAQ)](/img/b7/fb7ead787e00047f3663e8b5acfe33.jpg)
[design completion - opening report] zufeinfo 2018 software engineering major (including FAQ)
![[MySQL learning notes 22] index](/img/08/db7b765f7ddaa5706e3f7d00690d23.png)
[MySQL learning notes 22] index

Cubemx stm32f105rb USB flash drive reading and writing detailed tutorial

Vscode attempted to write the procedure to a pipeline that does not exist
随机推荐
从海量手机号中匹配某一个手机号
Opencv中的GrabCut图像分割
Set the location permission in the shutter to "always allow"
Huipay international permet au commerce électronique transfrontalier de devenir une plate - forme de paiement transfrontalière conforme!
Neat Syntax Design of an ETL Language (Part 2)
[competition -kab micro entrepreneurship competition] KAB National College Students' micro entrepreneurship action participation experience sharing (including the idea of writing the application form)
独步武林,架构选型手册(包含 PDF)
Cocopod error failed: undefined method `map 'for nil:nilclass
Voiceprint Technology (V): voiceprint segmentation and clustering technology
Download the arm64 package of Debian on X86 computer
Use evo
Match a mobile number from a large number of mobile numbers
CYCA 2022少儿形体礼仪初级师资班 深圳总部站圆满结束
Analysis on the thinking of 2022 meisai C question
2022 meisai question a idea sharing
Atguigu---18-component
将jar包注册为服务,实现开机自动启动
js工具函数,自己封装一个节流函数
[zero foundation understanding innovation and entrepreneurship competition] overall cognition and introduction of mass entrepreneurship and innovation competition (including FAQs and integration of bl
What are the PMP scores?