RxJS v4.1.0 Release Notes

Release Date: 2016-03-07 // about 8 years ago
  • ๐Ÿš€ We are happy to announce the release of RxJS version 4.1. With this release came a few new additions as well as a new system for pulling in what you want.

    Some of the changes are the following:

    • ๐Ÿ— Build What You Want with @rxjs/rx
    • โž• Adding repeatWhen
    • Parity with RxJS v5 names
    • Other changes

    ๐Ÿ— Build What You Want with @rxjs/rx

    ๐Ÿ— One of the biggest requests with RxJS was to build only what you wanted. In previous attempts, we looked at a CLI to build what you wanted, but that was suboptimal experience. Instead, we have ported the existing code base to CommonJS format so that it works right out of the box with Node.js, or with your favorite bundler whether it is Browserify, Webpack, Rollup, etc.

    0๏ธโƒฃ By default, this brings in all of RxJS when you require the @rxjs/rx module:

    const Rx = require('@rxjs/rx');const subscription = Rx.Observable.from([1,2,3]) .filter(x =\> x % 2 === 0) .map(x =\> x + 2) .subscribe(x =\> console.log(`The answer is ${x}`));// =\> The answer is 4 
    

    Now it is possible to bring in as much or as little as you want by only including the operators you want:

    const fromArray = require('@rxjs/rx/observable/fromArray');const filter = require('@rxjs/rx/observable/filter');const map = require('@rxjs/rx/observable/map');const source = fromArray([1,2,3]);const filtered = filter(source, x =\> x % 2 === 0);const mapped = map(filtered, x =\> x + 2);const subscription = mapped.subscribe( x =\> console.log(`The answer is ${x}`) );// =\> The answer is 4 
    

    Not only can you bring in certain operators, but you can also add each one to the prototype if you want the nice chaining feature as well.

    const Observable = require('@rxjs/rx/observable');// Add class methods Observable.addToObject({ fromArray: require('@rxjs/rx/observable/fromarray') });// Add instance methods Observable.addToPrototype({ filter: require('@rxjs/rx/observable/filter'), map: require('@rxjs/rx/observable/map') });const subscription = Observable.fromArray([1,2,3]) .filter(x =\> x % 2 === 0) .map(x =\> x + 2) .subscribe(x =\> console.log(`The answer is ${x}`));
    

    ๐Ÿ’… In addition, we also added some distributions that you will find under our src/modular/dist folder which contains all of RxJS built in a UMD style as well as a "lite" version as well. This should give you the building blocks for creating your own builds of RxJS and taking the only the operators you need.

    โž• Adding repeatWhen

    We often try to keep parity with other Rx versions such as RxJava. To that end, we've added repeatWhen which complements the retryWhen we've had for quite some time. Rather than buffering and replaying the sequence from the source Observable, the repeatWhen resubscribes to and mirrors the source Observable, but only conditionally based upon the Observable you return from the call.

    Here is an example where we can repeat a sequence twice with a delay of 200ms in between time.

    const source = Rx.Observable.just(42) .repeatWhen(function(notifications) { return notifications.scan((acc, x) =\> return acc + x, 0) .delay(200) .takeWhile(count =\> count \< 2); });var subscription = source.subscribe( x =\> console.log(`Next ${x}`, err =\> console.log(`Error ${err}`), () =\> console.log('Completed') );// =\> Next: 42// 200 ms pass// =\> Next: 42// 200 ms pass// =\> Completed
    

    Parity with RxJS v5 names

    Given the differences between RxJS v4 and RxJS v5, we've made the migration path easier by creating aliases for you such as the following:

    // Prototype methodsObservable.prototype.race = Observable.prototype.amb;Observable.prototype.mergeMap = Observable.prototype.flatMap;Observable.prototype.switchMap = Observable.prototype.flatMapLatest;Observable.prototype.exhaustMap = Observable.prototype.flatMapFirst;Observable.prototype.exhaust = Observable.prototype.switchFirst;Observable.prototype.publishReplay = Observable.prototype.replay;// Object methodsObservable.bindCallback = Observable.fromCallback;Observable.bindNodeCallback = Observable.fromNodeCallback;Observable.race = Observable.amb;
    

    Other Changes

    • ๐Ÿ› Bug fixes such as to ConnectableObservable so that if the underlying Subject has been disposed, we will no longer attempt to resubscribe to it.
    • โฑ The startWith operator no longer uses Scheduler.currentThread and now uses Scheduler.immediate, as that caused issues with the backpressure operators such as pausable and pausableBuffered.
    • ๐Ÿ“š Documentation bug fixes

Previous changes from v4.0.6

  • ๐Ÿš€ This is a bug fix release of the Reactive Extensions for JavaScript (RxJS) for version 4.0 to fix a number of issues. The most prominent being the issue with fromPromise(promise) was swallowing errors from Observable instances which is now fixed. Looking forward, we will continue to work on performance as well as the modular design for those who want to pick and choose which pieces from NPM they want to use.

    ๐ŸŽ Performance Work

    ๐ŸŽ Work continued on performance with Rx.Observable.onErrorResumeNext, Rx.Observable.mergeDelayError as well as our join patterns. Expect this to continue throughout the lifecycle of v4.x.

    ๐Ÿ› Bugs Fixed:

    ๐Ÿš€ These were the bugs fixed during this release since 4.0.0:

    • โฑ #969 - fix for timeout without other Observable
    • โœ… #964 - fixed shared state for zip, combineLatest and withLatestFrom in subscribeCore
    • ๐Ÿš€ #963 - Angular broken with latest release
    • #957 - fix issue with fromEvent not firing
    • #955 - rx.d.ts compilation issue fix
    • #949 - add null handling for isIterable check
    • #947 - add initialValue to publishValue.md
    • #941 - fix for timer which was firing immediately
    • ๐Ÿ“š #939 - documentation fix for find
    • 0๏ธโƒฃ #938 - fix defaultIfEmpty with default value.
    • #936 - fix fromPromise behavior not to swallow errors when used with Rx.Observable.spawn
    • #934 - fix BehaviorSubject inheritance from Observer
    • #932 - include zip in TypeScript exports
    • ๐Ÿ”€ #931 - include merge in TypeScript exports