Reactive Extensions Configuration
Configuration information for the Reactive Extensions for JavaScript
Documentation
Rx.config.Promise
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
Rx.config.Promise = RSVP.Promise;
var p = Rx.Observable.just(1).toPromise()
.then(function (value) { console.log('Value: %s', s); });
// => Value: 1
Rx.config.useNativeEvents
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.
<script src="jquery.js"></script>
<script src="rx.lite.js"></script>
We can do this by setting the Rx.config.useNativeEvents
flag to true
.
Rx.config.useNativeEvents = true;
Rx.Observable.fromEvent(document, 'mousemove')
.subscribe(function (e) {
console.log('ClientX: %d, ClientY: %d', e.clientX, e.clientY);
});