RxJS v4.0
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 value | Multiple return values | |
---|---|---|
Pull/Synchronous/Interactive | Object | Iterables(Array | Set | Map) |
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 | Observable |
|
|
There are a number of ways of getting started with RxJS including:
- Getting Started With RxJS
- RxJS Guidelines
- Getting to Know RxJS Libraries
- How Do I?
- Mapping RxJS from Different Libraries
- API Documentation
Getting Started With RxJS
Getting started with the Reactive Extensions for JavaScript is easy. Let's start with the basics here:
- What are the Reactive Extensions?
- Exploring Major Concepts in RxJS
- Creating and Querying Observable Sequences
- Creating and Subscribing to Simple Observable Sequences
- Bridging to Events
- Bridging to Callbacks
- Bridging to Promises
- Generators and Observable Sequences
- Querying Observable Sequences
- Error Handling With Observable Sequences
- Transducers with Observable Sequences
- Backpressure with Observable Sequences
- Operators by Category
- Which Operator do I use?
- Subjects
- Scheduling and Concurrency
- Testing and Debugging
- Implementing Your Own Operators
RxJS Guidelines
Curious on how we designed RxJS? This is covered along with overall guidelines of how your RxJS code should operate. In addition, we have contribution guidelines which set the bar for which we accept contributions.
Getting to Know RxJS Libraries
There are many libraries that make up the Reactive Extensions for JavaScript, so it may be a little daunting at first to know which ones to include. This will serve as a guide for which libraries you might need. For most operations you'll only need rx.lite.js
, but you may find you need more operators, so you start with rx.js
and add additional files to mix in functionality as you need it.
The complete library:
Main Libraries:
rx.js
rx.aggregates.js
rx.async.js
rx.binding.js
rx.coincidence.js
rx.experimental.js
rx.joinpatterns.js
rx.testing.js
rx.time.js
rx.virtualtime.js
Lite Libraries:
rx.lite.js
rx.lite.extras.js
rx.lite.aggregates.js
rx.lite.async.js
rx.lite.coincidence.js
rx.lite.experimental.js
rx.lite.joinpatterns.js
rx.lite.testing.js
rx.lite.time.js
rx.lite.virtualtime.js
Core Libraries:
How Do I?
There is a large surface area with the Reactive Extensions for JavaScript, so it might be hard to know where to start. This will serve as a guide to answer some of the more basic questions.
- How do I wrap an existing API?
- How do I integrate jQuery with RxJS?
- How do I integrate Angular.js with RxJS?
- How do I create a simple event emitter?
Mapping RxJS from Different Libraries
Converting your existing code from other libraries can be easy. Many of the concepts you already know from popular libraries such as Bacon.js and Async.js
- For Bacon.js Users
- For Async.js Users
- For Highland.js Users
Reactive Extensions Class Library
This section contains the reference documentation for the Reactive Extensions class library.
Helpers
Core
Subjects
Schedulers
Disposables
Rx.CompositeDisposable
Rx.Disposable
Rx.RefCountDisposable
Rx.SerialDisposable
Rx.SingleAssignmentDisposable