当前位置:网站首页>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
withLatestFrom
Put 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 :
边栏推荐
- 力扣-104. 二叉树的最大深度
- Reza RA series - development environment construction
- 如何自制一个安装程序,将程序打包生成安装程序的办法
- Download the arm64 package of Debian on X86 computer
- 8. Intelligent transportation project (1)
- CyCa 2022 children's physical etiquette primary teacher class Shenzhen headquarters station successfully concluded
- oracle 函数 触发器
- 纳米数据世界杯数据接口,中超数据,体育数据比分,世界杯赛程api,足球比赛实时数据接口
- 股票在线开户安全吗?找谁可以办理?
- manhattan_ Slam environment configuration
猜你喜欢
Voiceprint Technology (VI): other applications of voiceprint Technology
Reza RA series - development environment construction
CYCA少儿形体礼仪 乐清市培训成果考核圆满落幕
Puzzle (019.2) hexagonal lock
Tiktok brand goes to sea: both exposure and transformation are required. What are the skills of information flow advertising?
Ruiji takeout project (II)
How to delete a blank page that cannot be deleted in word
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
Title B of the certification cup of the pistar cluster in the Ibagu catalog
Format analysis and explanation of wav file
随机推荐
PMP考试多少分算通过?
请问在手机上开户股票,还是去证券公司开户安全?
[IOU] intersection over union
[buuctf.reverse] 121-125
8、智慧交通项目(1)
Analysis on the thinking of 2022 meisai C question
Shuttle JSON, list, map inter transfer
Creating a binary tree (binary linked list) from a generalized table
Cubemx stm32f105rb USB flash drive reading and writing detailed tutorial
pmp考试题型需要注意哪些?
Solution to the problem of repeated startup of esp8266
富时A50开户什么地方安全
从海量手机号中匹配某一个手机号
纳米数据世界杯数据接口,中超数据,体育数据比分,世界杯赛程api,足球比赛实时数据接口
Wechat official account can reply messages normally, but it still prompts that the service provided by the official account has failed. Please try again later
[wechat applet full stack development course] course directory (mpvue+koa2+mysql)
How to make a self-made installer and package the program to generate an installer
Is the client that gets the scanning code wechat or Alipay
Voiceprint Technology (I): the past and present life of voiceprint Technology
Voiceprint Technology (III): voiceprint recognition technology