[RxJS] Reactive Programming - What is RxJS?
First thing need to understand is, Reactive programming is dealing with the event stream.
Event streams happens overtime, which not stay in the memory.
For example, the array we have:
var source = ['1', '1', 'foo', '2', '3', '5', 'bar', '8', '13'];
Which is stay in the momery.
But the stream we have:
let logic = Rx.Observable.interval(400).take(9)
.map( (i) => {
let val = ['1', '1', 'foo', '2', '3', '5', 'bar', '8', '13'][i]
return parseInt(val, 10);
})
Which happens overtime, every 400ms it return an Interge if possible.
So the main difference between array stay in memory and the events streams is array already stay in memory and the streams happens overtime.
But the nice things about the stream is we can still use the methods we have for array:
let logic = Rx.Observable.interval(400).take(9)
.map( (i) => {
let val = ['1', '1', 'foo', '2', '3', '5', 'bar', '8', '13'][i]
return parseInt(val, 10);
})
.filter( (number) => {
return !isNaN(number)
})
.reduce( (acc, y) => {
return acc + y;
} ); let effect = logic.subscribe( (number) => {
console.log(number);
});
[RxJS] Reactive Programming - What is RxJS?的更多相关文章
- [RxJS] Reactive Programming - Why choose RxJS?
RxJS is super when dealing with the dynamic value. Let's see an example which not using RxJS: var a ...
- [RxJS] Reactive Programming - Clear data while loading with RxJS startWith()
In currently implemention, there is one problem, when the page load and click refresh button, the us ...
- [RxJS] Reactive Programming - Rendering on the DOM with RxJS
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery- ...
- [RxJS] Reactive Programming - Using cached network data with RxJS -- withLatestFrom()
So now we want to replace one user when we click the 'x' button. To do that, we want: 1. Get the cac ...
- [RxJS] Reactive Programming - Sharing network requests with shareReplay()
Currently we show three users in the list, it actually do three time network request, we can verfiy ...
- [RxJS] Reactive Programming - New requests from refresh clicks -- merge()
Now we want each time we click refresh button, we will get new group of users. So we need to get the ...
- [Reactive Programming] RxJS dynamic behavior
This lesson helps you think in Reactive programming by explaining why it is a beneficial paradigm fo ...
- .Net中的反应式编程(Reactive Programming)
系列主题:基于消息的软件架构模型演变 一.反应式编程(Reactive Programming) 1.什么是反应式编程:反应式编程(Reactive programming)简称Rx,他是一个使用LI ...
- [Reactive Programming] Using an event stream of double clicks -- buffer()
See a practical example of reactive programming in JavaScript and the DOM. Learn how to detect doubl ...
随机推荐
- C# 导出Excel 多个Sheet
以下代码中最关键的代码是 Worksheet mSheet = (Microsoft.Office.Interop.Excel.Worksheet)mBook.Worksheets.Add(miss, ...
- wp8模拟器操作键盘
当前焦点在模拟器上的某一个输入控件上时候, 按pagedown/pageup可以切换是用pc键盘还是模拟器键盘
- redis数据结构与主要命令
redis的数据类型有:string.hashes.lists.sets,sorted sets 1.string类型: set.get添加键值对获得键值对.如果多次赋值会覆盖掉原来的value se ...
- C# 获取当前路径
// 获取程序的基目录.System.AppDomain.CurrentDomain.BaseDirectory F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug\ ...
- 【Python学习】指定两点地理位置经纬度的距离计算
指定两点地理位置经纬度的距离计算 #coding=utf-8 from math import * # input Lat_A 纬度A # input Lng_A 经度A # input Lat_B ...
- pyqt5模块
- [linux] linux知识积累(不断更新中…)
一.vim知识 f(find)命令也可以用于移动,fx将找到光标后第一个为x的字符,3fd将找到第三个为d的字符. D 删除当前字符至行尾.D=d$ :split或new 打开一个新窗口,光标停在顶层 ...
- jquery中checkbox全选失效的解决方法
这篇文章主要介绍了jquery中checkbox全选失效的解决方法,需要的朋友可以参考下 如果你使用jQuery 1.6 ,代码if ( $(elem).attr(“checked”) ),将 ...
- Linux - Reset a MySQL root password
Use the following steps to reset a MySQL root password by using the command line interface. Stop the ...
- WordPress插件开发记录
1.a标签在新的网页中打开内容 <a href="网址" target="_blank"></a> 2.PDO的$re ...