View ix-example.js
1 2 3 4 5 6 7 8 9 10
function* fibonacci(){
var fn1 = 1;
var fn2 = 1;
while (1){
var current = fn2;
fn2 = fn1;
fn1 = fn1 + current;
yield current;
}
}
View example.js
1 2 3 4 5 6 7 8 9
function include (jsFile) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(jsFile),
s = f.ReadAll();
f.Close();
return s;
}
 
eval(include('C:\\GitHub\\RxJS\\dist\\rx.all.compat.js'));
View tomap.js
1 2 3 4 5 6 7 8 9 10
/**
* Converts the observable sequence to a WeakMap if it exists.
* @param {Function} keySelector A function which produces the key for the WeakMap
* @param {Function} [elementSelector] An optional function which produces the element for the WeakMap. If not present, defaults to the value from the observable sequence.
* @returns {Observable} An observable sequence with a single value of a WeakMap containing the values from the observable sequence.
*/
function toMap(source, type, keySelector, elementSelector) {
return new AnonymousObservable(function (observer) {
var m = new type();
return self.subscribe(
View toset.js
1 2 3 4 5 6 7 8 9 10
function toSet(source, type) {
return new AnonymousObservable(function (observer) {
var s = new type();
return source.subscribe(
s.add.bind(s),
observer.onError.bind(observer),
function () {
observer.onNext(s);
observer.onCompleted();
})
View eventsource.js
1 2 3 4 5 6 7 8 9 10
if (!!root.EventSource) {
 
/**
* This method wraps an EventSource as an observable sequence.
* @param {String} url The url of the server-side script.
* @param {Observer} [openObserver] An optional observer for the 'open' event for the server side event.
* @returns {Observable} An observable sequence which represents the data from a server-side event.
*/
dom.fromEventSource = function (url, openObserver) {
return new AnonymousObservable(function (observer) {
View canvaspaint.html
1 2 3 4 5 6 7 8 9 10
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
<title>Rx for JavaScript Rocks!</title>
<link rel="stylesheet" href="../vendor/bootstrap-3.2.0/css/bootstrap.min.css">
View events.js
1 2 3 4 5 6 7 8 9 10
(function () {
var events = "blur focus focusin focusout load resize scroll unload click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup error contextmenu";
 
if (root.PointerEvent) {
events += " pointerdown pointerup pointermove pointerover pointerout pointerenter pointerleave";
}
 
events = events.split(' ');
View RxBus.js
1 2 3 4 5 6 7 8 9 10
function RxBus() {
 
function remove(xs, x) {
xs.splice(xs.indexOf(x), 1);
}
 
function innerSubscription(observable) {
var disposable;
 
function cancel() { remove(subscriptions, subscription); }
View pirx.js
1 2 3 4 5 6 7 8 9 10
function pi(k) {
return ( k % 2 === 0 ? -4 : 4) / (( 2 * k ) - 1 );
}
 
var total = Rx.Observable.range(1, 10000000, Rx.Scheduler.timeout)
.map(pi)
.sum();
 
total.subscribe(function (x) { console.log(x); });
//=> 3.1415925535897915
View deferconcat.cs
1 2 3 4 5 6 7 8
var source1 = Observable.Return(42);
var source2 = source1.Concat(Observable.Defer(() =>
{
Console.WriteLine("Deferred");
return Observable.Return(56);
}));
 
source2.Take(1).Subscribe(Console.WriteLine);
Something went wrong with that request. Please try again.