当前位置:网站首页>Rxjs Observable. Execute logical analysis of pipe passing in multiple operators
Rxjs Observable. Execute logical analysis of pipe passing in multiple operators
2022-06-11 10:50:00 【Hua Weiyun】
Test code :
fromEvent(this.test, 'click').pipe(map( event => event.timeStamp), mapTo(1)).subscribe((event) => console.log(event));pipe The two input operations of the operation :
The input parameter is an array , Contains two elements :
Use the original Observable As input , Perform these two operations :
Array of reduce It's a native method :
Here's the code , It introduces reduce Usage of :
<html><script>var a = [1,2,3,4];function fn(pre, cur, index, arr){ console.log(`previous: ${pre}, cur: ${cur}, index: ${index}, whole arr: ${arr}`); return pre + cur;}console.log(a.reduce( fn, 0));</script></html>reduce Take two parameters , The first argument is a function , This function receives 4 Three input parameters ,previous,current,index and array:
- previous: The previous round reduce Iteration value , If the first round , Then the value is the second parameter , That's the initial value
- current: The current round of reduce Iteration value . for example ,array Element is 1,2,3,4, be reduce Every iteration ,current Values, respectively 1,2,3,4
- index: Iterated index values
- array: call reduce The original array of , With the previous index Parameters , Access to the contents of the entire array

In actual use ,previous and current These two parameters are used most .
go back to pipeFromArray The implementation of the .

reduce First iteration :
prev yes input The initial value passed in ,fn It's input fns The first element of the array . That is the first one. map Back to operator:

There will be no specific implementation here map operation , But back to a new one Observable object , As a second round reduce The input to the iteration :

lift The way is to return the new Observable object :

mapTo The implementation of the :
after pipe Processed Observable, Finally, the application subscribes to , This is the final version of Observable:

边栏推荐
- [MySQL] use of stored procedures
- Migrating minini to littlefs
- 95后大厂程序员删库被判刑!只因项目被接手对领导心生不满
- 国际多语言出海商城返佣产品自动匹配订单源码
- C#入门系列(十一) -- 多维数组
- NFT 2.0: 下一代的NFT将是精简且值得信赖的NFT
- Tiktok encounters cultural conflict in the UK, and many employees leave in a short time
- Série de démarrage C # (XI) - - tableaux multidimensionnels
- 使用 Feign 实现声明式 REST 调用
- Gamefi: everything you need to know about the "play and earn" game economy
猜你喜欢

Fix the problem that uicollectionview does not reach the bottom security zone

为什么说Web3会是「创作者经济」的游戏规则改变者

白屏时间、首屏时间

Arbitrum infrastructure: a quick start

VMware install win7 virtual machine

NFT will change data ownership in the metauniverse
![[games101] operation 2 -- triangle rasterization](/img/43/1a58206b8b7e6d19d2944cdb7bb0dc.png)
[games101] operation 2 -- triangle rasterization

金仓数据KingbaseES 批量创建数据库对象

【GAMES101】作业2--三角形光栅化

beginning一款非常优秀的emlog主题
随机推荐
NGUI,背包拖拽,以及随机克隆图片知识点
网上开户是安全的吗?普通人可以开吗?
Safety related website recommendations
EMC rectification cases of electronic equipment radiation
Fix the problem that uicollectionview does not reach the bottom security zone
FPGA infrastructure [reference ug998]
Dimension types for different CV tasks
NewOJ Week 2---BCD
Jszip get the file of the specified file in the uploaded zip package
Global pooling – pytoch
Where is it safer to open an account for soda ash futures? How much money can you do?
NGUI,选择性别男女
Implementing declarative rest calls using feign
Waiting event enq: Ko - some feasible processing methods for fast object checkpoint
Some understanding of inductive bias
Pl/sql compilation check in kingbasees
新西兰是道路安全做的最好的国家之一
Série de démarrage C # (XI) - - tableaux multidimensionnels
白屏时间、首屏时间
Team level safety training, new employee induction training education courseware, full content ppt application