[RxJS] Reactive Programming - What is RxJS?
is Rxjs What Programming reactive
2023-09-14 09:00:54 时间
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); });
相关文章
- Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/Type
- TypeError: 'bases' is null or not an object。IE8 bug 腐朽的对象
- [Vue-rx] Disable Buttons While Data is Loading with RxJS and Vue.js
- C#中数据类型的安全转换(is,as)
- new sap.ui.core.Item() - how is it initialized
- How is new Appoinment id generated in my task followup scenario
- association in CDS view is converted to LEFT OUTER MANY TO ONE JOIN in the runtime
- how Kyma connection is established for the first time
- 005. how is RFC to backend determined - maintenance view IWFNDV_MGDEAM
- 成功解决You are using pip version 9.0.3, however version 10.0.1 is available. You should consider upgr
- 已解决FutureWarning: As the xlwt package is no longer maintained, the xlwt engine will be removed in
- kafka.common.KafkaException: Failed to acquire lock on file .lock in /tmp/kafka-logs. A Kafka instance in another process or thread is using this directory.
- The specified Android SDK Build Tools version (23.0.2) is ignored,