BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Reactive Extensions for JavaScript Loses Weight and Older Browsers

Reactive Extensions for JavaScript Loses Weight and Older Browsers

RxJS 2.2 loses weight by only supporting ECMA Script 5 browsers in the default build. This means using Reactive Extensions for JavaScript by itself requires IE 9, Firefox 4, Safari 6, Chrome 19, and later browsers. Those wishing to support older browsers may use rx.compact.js to supply the missing polyfills.

To further reduce the footprint, developers can use Rx-Lite. Also known as rx.lite.js, this library only includes the most commonly used features. From the Rx Team blog,

Instead of the a la carte tradition of RxJS, using only the pieces you need, this build has the most commonly used operators from factory methods, standard query operators, time-based operators, binding operators such as multicast, and async operators such as Rx.Observable.fromEvent, Rx.Observable.fromPromise and more in the form of rx.lite.js. We also have a compatibility version which supports older browsers in rx.lite.compat.js. The size of the entire library is about 7kb gzipped, which offers a lot of possibilities without much cost.

Like the full version, RX-Lite is designed for ECMAScript 5 with an optional compatibility library for older browsers.

There are some other breaking changes in RxJS 2.2. First is the behavior of Rx.Observable.prototype.scan, which “was also changed as it was in the Reactive Extensions for .NET.” The announcement continues,

This is to reflect behavior found in other languages such as F#, Haskell and others. The basic rule is, if you have an empty observable sequence with a seed, then you should yield that seed, else if it is an empty sequence with no seed, it should be an empty sequence. This breaks from the old behavior which yielded nothing with an empty observable sequence even when it had a seed.

The other change is moving four functions to new libraries:

  • Rx.Observable.toAsync moved to rx.async.js
  • Rx.Observable.start moved to rx.async.js
  • Rx.HistoricalScheduler moved to rx.virtualtime.js
  • Rx.VirtualTimeScheduler moved to rx.virtualtime.js

Again, this was to reduce the size of the core file. We’ll cover the rx.async.js in more depth in Monday’s report on the future of RxJS.

Rate this Article

Adoption
Style

BT