github Reactive-Extensions/RxJS v2.3.18
RxJS version 2.3.18

latest releases: v4.1.0, v4.0.8, v4.0.7...
9 years ago

This is a minor update from version 2.3.14. This release will probably be one of the last in the version 2.3 series before we start on the more ambitious plans for 2.4 including mirroring the lift based approach of RxJava, as well as backpressure built into the subscription level instead of the operator level, as well as plans for expression tree parsing.

In coming releases, we are going to try and get rid of some of our technical debt including some of our poorly named operators such as throttle which we discuss below as well as other ones such as fromArray instead of using from.

The major items for this release are:

  • Backpressure Fixes
  • Debounce and Throttle Changes
  • Scheduler Changes
  • Testing with Promises
  • JSCS and Google Coding Standards Enforcement
  • Improved Documentation

Backpressure Fixes

There was an issue with a prior release of the pausableBuffered operator which was noted in issue #349 where if the stream ended before the stream resumed, data would have been automatically pushed anyhow. In addition, there were issues where errors were immediately processed regardless of whether the stream was in a paused state. Those two bugs have now been fixed and can be verified with these test cases.

Success Case

  var scheduler = new TestScheduler();

  var results = scheduler.createObserver();

  var xs = scheduler.createHotObservable(
    onNext(150, 1),
    onNext(210, 2),
    onNext(230, 3),
    onNext(301, 4),
    onNext(350, 5),
    onNext(399, 6),
    onNext(450, 7),
    onNext(470, 8),
    onCompleted(500)
  );

  var controller = scheduler.createHotObservable(
    onNext(201, true),
    onNext(300, false),
    onNext(600, true)
  );

  var results = scheduler.startWithCreate(function () {
    return xs.pausableBuffered(controller);
  });

  results.messages.assertEqual(
    onNext(210, 2),
    onNext(230, 3),
    onNext(600, 4),
    onNext(600, 5),
    onNext(600, 6),
    onNext(600, 7),
    onNext(600, 8),
    onCompleted(600)
  );

Error Case

var error = new Error();

var scheduler = new TestScheduler();

var results = scheduler.createObserver();

var xs = scheduler.createHotObservable(
  onNext(150, 1),
  onNext(210, 2),
  onNext(230, 3),
  onNext(301, 4),
  onNext(350, 5),
  onNext(399, 6),
  onNext(450, 7),
  onNext(470, 8),
  onError(500, error)
);

var controller = scheduler.createHotObservable(
  onNext(201, true),
  onNext(300, false),
  onNext(600, true)
);

var results = scheduler.startWithCreate(function () {
  return xs.pausableBuffered(controller);
});

results.messages.assertEqual(
  onNext(210, 2),
  onNext(230, 3),
  onNext(600, 4),
  onNext(600, 5),
  onNext(600, 6),
  onNext(600, 7),
  onNext(600, 8),
  onError(600, error)
);

As you will note, the values are yielded after the sequence had already ended and instead were yielded when the controller resumed.

Debounce and Throttle Changes

There has been a bit of confusion around some of the operators in RxJS such as throttle. Our version of throttle acted instead of a throttling operator, it acted more as a debounce operator. RxJava, while designing their APIs came across this inconsistency This was noted in issue #352 where we would deprecate throttle in favor of debounce or throttleWithTimeout. Note that in upcoming versions, warnings will occur to stop using throttle. We also introduced throttleFirst which acts as a proper throttle is expected to do. Thanks to @L8D for the help!

Scheduler Changes

Node.js Recently made some changes in the 10.x release where warnings would occur if the use of process.nextTick were used for a recursive function call. This caused issues in any number of our time-based operators as noted in issue #344. To fix this, we simply changed the order to use setImmediate if available in Node.js, else default back to process.nextTick for older versions in the Rx.Scheduler.timeout.

Testing with Promises

RxJS prides itself on deterministic testing with virtual time. As RxJS has evolved, we have added Promise support to many of our operators as noted in our Bridging to Promises documentation. This was addressed in issue #331 where you have the ability to create both a resolved and rejected Promise which is synchronous and records in virtual time via the createResolvedPromise and createRejectedPromise on the Rx.TestScheduler class.

Now you can test using these Promises for exact timing information!

Resolved Promise

var scheduler = new TestScheduler();

var xs = scheduler.createResolvedPromise(201, 1);

var results = scheduler.startWithCreate(function () {
  return Observable.fromPromise(xs);
});

results.messages.assertEqual(
  onNext(201, 1),
  onCompleted(201)
);

Rejected Promise

var error = new Error();

var scheduler = new TestScheduler();

var xs = scheduler.createRejectedPromise(201, error);

var results = scheduler.startWithCreate(function () {
  return Observable.fromPromise(xs);
});

results.messages.assertEqual(
  onError(201, error)
);

This now makes testing when using Promises in your API a snap!

JSCS and Google Coding Standards Enforcement

RxJS has fairly rigid coding guidelines as outlined in our Design Guidelines and our Contribution Guidelines. To enforce this, we have added JSCS to our Grunt-based build system to include the rules that Google uses for their JavaScript Style Guide as noted in issue #359. Thanks to @hzoo for making this happen.

Improved Documentation

Documentation has been one of the biggest focus areas for learning RxJS. To that end, we've added a number of documents that are helpful in learning RxJS including:

Many thanks to @trxcllnt for the help on the which operators to use.

Don't miss a new RxJS release

NewReleases is sending notifications on new releases.