Back to Rxjs

This is RxJS v 4. Find the latest version here

doc/api/config/readme.md

4.1.02.3 KB
Original Source

This is RxJS v 4. Find the latest version here

Reactive Extensions Configuration

Configuration information for the Reactive Extensions for JavaScript

Documentation


<a id="rxconfigpromise"></a>Rx.config.Promise

<a href="#rxconfigpromise">#</a> [Ⓣ][1]

Sets the default Promise type to be used when the toPromise method is called. Note that the Promise implementation must conform to the ES6 specification. Some of those supported libraries are Q, RSVP, when.js among others. If not specified, this defaults to the native ES6 Promise, if available, else will throw an error.

Example

js
Rx.config.Promise = RSVP.Promise;

var p = Rx.Observable.just(1).toPromise()
  .then(function (value) { console.log('Value: %s', s); });
// => Value: 1

<a id="rxconfigusenativeevents"></a>Rx.config.useNativeEvents

<a href="#rxconfigusenativeevents">#</a> [Ⓣ][1]

Determines whether the fromEvent method uses native DOM events only and disregards the referenced supported libraries such as jQuery, Zepto.js, AngularJS, Ember.js and Backbone.js

Example

For example, we could have jQuery referenced as part of our project, however, we only want native DOM events.

html
<script src="jquery.js"></script>
<script src="rx.lite.js"></script>

We can do this by setting the Rx.config.useNativeEvents flag to true.

js
Rx.config.useNativeEvents = true;

Rx.Observable.fromEvent(document, 'mousemove')
  .subscribe(function (e) {
    console.log('ClientX: %d, ClientY: %d', e.clientX, e.clientY);
  });