[RxJS] Reactive programming-why Choose RxJS?

Source: Internet
Author: User

RxJS is super when dealing with the dynamic value.

Let's see a example which not using RxJS:

var a = 4; var b = A * Ten//  + = 5//  

So to change a, it won ' t affect B's value because B is already defined ....

So if you want B get sideeffect, you need to declear it again:

var a = 4; var b = A * Ten//  = 5 = A *//  

And also, many a time, it may happened so you found the variable had been mutated, but you had no idea where and how.

So using RxJS:

var streama = Rx.Observable.interval (+). Take (5); var streamb = streama.map (num) = {  return num *console.log (b));

So now, Streama arrivals at every 400ms, we can take 4 of the those. Then we map to Streamb.

Then on the console, you'll see the value would change according to the value of stream A.

[RxJS] Reactive programming-why Choose RxJS?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.