BT

Reactive Extensions for JavaScript Loses Weight and Older Browsers

by Jonathan Allen on Dec 19, 2013 |

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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Rx rocks by wakin imgen

Rx is great, with this release, I think it's even more fun to code it with

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT