aasiutin / rx-book

Home Page:xgrommx.github.io/rx-book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RxJS

Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators.

Data sequences can take many forms, such as a stream of data from a file or web service, web services requests, system notifications, or a series of events such as user input.

Reactive Extensions represents all these data sequences as observable sequences. An application can subscribe to these observable sequences to receive asynchronous notifications as new data arrive.

RxJS has no dependencies which complements and interoperates smoothly with both synchronous data streams such as iterable objects in JavaScript and single-value asynchronous computations such as Promises as the following diagram shows:

Single return valueMutiple return values
Pull/Synchronous/Interactive Object Iterables (Array | Set | Map | Object)
Push/Asynchronous/Reactive Promise Observable

To put it more concretely, if you know how to program against Arrays using the Array#extras, then you already know how to use RxJS!

Example code showing how similar high-order functions can be applied to an Array and an Observable
Iterable
getDataFromLocalMemory()
             .filter (function (s) { return s != null; })
             .map( function (s) { return s + 'transformed'; })
             .forEach(function (s) { console.log('next => ' + s); })
Observable
getDataFromNetwork()
          .filter (function (s) { return s != null; })
          .map( function (s) { return s + 'transformed'; })
          .subscribe(function (s) { console.log('next => ' + s); })

About

xgrommx.github.io/rx-book


Languages

Language:CSS 62.8%Language:JavaScript 37.2%