This post will focus on what’s inside and how you can get started.
RxJS consists of the following files and we’ll cover the details of each in subsequent posts:
- rx.js – the main library for the Reactive Extensions
- rx.aggregates.js – aggregation operators such as min/max, count, sum, and average
- rx.binding.js – binding operators such as multicast, publish and replay
- rx.coincidence.js – coincidence operators such as join, and groupJoin
- rx.experimental.js – experimental operators such as the imperative operators and forkJoin
- rx.joinpatterns.js – join pattern calculus implementation
- rx.testing.js – used to write unit tests for complex processing queries
- rx.time.js – time-based event processing query operations
Installing with NuGet
The first option of getting RxJS is through NuGet. Starting with Visual Studio 2012, NuGet is automatically built in, but for previous versions you can install via www.nuget.org
. We have a number of packages in NuGet which correspond to the names of our files from above. Each package contains the source file, as well as the documentation via a VSDoc file, and a minimized version.
We ship the following packages in NuGet:
In addition to these main packages, we will continue to deliver the bridges to other libraries such as jQuery, Dojo, MooTools, ExtJS and more. Just search for RxJS-Bridges to find them all.
Installing with NPM and Node.js
To get started, just install rx from NPM from a command window.
Once installed, you can reference RxJS like the following example of returning a single value and then writing the value to the console when we subscribe.
RxJS, with its emphasis on querying streams of data, is really well suited for Node.js applications. We’ll explore more of RxJS and Node.js in subsequent posts
Asynchronous Module Definition (AMD) support
In the following example, we can use Require.js to load both the main RxJS library as well as the time-based operators to build a simple observable sequence which writes to the console every half second.
How Do I Get Started…
One of the often asked questions when it comes to RxJS is how one gets started using the library. This To that end, we’ve created a GitHub repository especially for our samples called RxJS-Examples. This is just a sampling of some of the examples we have which highlight some of the Reactive Extensions capabilities.
- Autocomplete (source) (demo)
An autocomplete scenario which throttles typing to query Wikipedia for search suggestions.
- Canvas Painting (source) (demo)
Painting on a HTML5 Canvas.
- Drag and Drop (source) (demo)
Drag and Drop example with the Volta logo.
- AMD and Require.js Integration (source) (demo)
Integration of the Asynchronous Module Definition pattern, Require.js and RxJS.
- Time Flies Like an Arrow (source) (demo)
A time based delay for each letter based upon its position .
- Testing using QUnit (source) (demo)
Unit testing example using QUnit showing how you can test the timing aspects of observable sequences.
- Testing using Node.js and Mocha (source)
Unit testing example with Mocha and Node.js, which shows how to test the timings of observable sequences.
This is just the start of some of the samples and we’ll be posting more in the near future as well as more complete documentation.