rxjs-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +14 -0
- data/lib/rxjs/rails/engine.rb +7 -0
- data/lib/rxjs/rails/railtie.rb +7 -0
- data/lib/rxjs/rails/version.rb +7 -0
- data/lib/rxjs/rails.rb +8 -0
- data/lib/rxjs.rb +1 -0
- data/rxjs-rails.gemspec +22 -0
- data/vendor/assets/javascripts/rx.aggregates.js +687 -0
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -0
- data/vendor/assets/javascripts/rx.async.compat.js +376 -0
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -0
- data/vendor/assets/javascripts/rx.async.js +306 -0
- data/vendor/assets/javascripts/rx.async.min.js +1 -0
- data/vendor/assets/javascripts/rx.binding.js +561 -0
- data/vendor/assets/javascripts/rx.binding.min.js +1 -0
- data/vendor/assets/javascripts/rx.coincidence.js +691 -0
- data/vendor/assets/javascripts/rx.coincidence.min.js +1 -0
- data/vendor/assets/javascripts/rx.compat.js +4351 -0
- data/vendor/assets/javascripts/rx.compat.min.js +2 -0
- data/vendor/assets/javascripts/rx.experimental.js +453 -0
- data/vendor/assets/javascripts/rx.experimental.min.js +1 -0
- data/vendor/assets/javascripts/rx.joinpatterns.js +418 -0
- data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -0
- data/vendor/assets/javascripts/rx.lite.compat.js +5188 -0
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -0
- data/vendor/assets/javascripts/rx.lite.js +5000 -0
- data/vendor/assets/javascripts/rx.lite.min.js +2 -0
- data/vendor/assets/javascripts/rx.min.js +2 -0
- data/vendor/assets/javascripts/rx.node.js +143 -0
- data/vendor/assets/javascripts/rx.testing.js +503 -0
- data/vendor/assets/javascripts/rx.testing.min.js +1 -0
- data/vendor/assets/javascripts/rx.time.js +1166 -0
- data/vendor/assets/javascripts/rx.time.min.js +1 -0
- data/vendor/assets/javascripts/rx.virtualtime.js +336 -0
- data/vendor/assets/javascripts/rx.virtualtime.min.js +1 -0
- metadata +101 -0
@@ -0,0 +1,306 @@
|
|
1
|
+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
2
|
+
|
3
|
+
;(function (factory) {
|
4
|
+
var objectTypes = {
|
5
|
+
'boolean': false,
|
6
|
+
'function': true,
|
7
|
+
'object': true,
|
8
|
+
'number': false,
|
9
|
+
'string': false,
|
10
|
+
'undefined': false
|
11
|
+
};
|
12
|
+
|
13
|
+
var root = (objectTypes[typeof window] && window) || this,
|
14
|
+
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
15
|
+
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
16
|
+
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
17
|
+
freeGlobal = objectTypes[typeof global] && global;
|
18
|
+
|
19
|
+
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
20
|
+
root = freeGlobal;
|
21
|
+
}
|
22
|
+
|
23
|
+
// Because of build optimizers
|
24
|
+
if (typeof define === 'function' && define.amd) {
|
25
|
+
define(['rx', 'exports'], function (Rx, exports) {
|
26
|
+
root.Rx = factory(root, exports, Rx);
|
27
|
+
return root.Rx;
|
28
|
+
});
|
29
|
+
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
30
|
+
module.exports = factory(root, module.exports, require('./rx'));
|
31
|
+
} else {
|
32
|
+
root.Rx = factory(root, {}, root.Rx);
|
33
|
+
}
|
34
|
+
}.call(this, function (root, exp, Rx, undefined) {
|
35
|
+
|
36
|
+
// Aliases
|
37
|
+
var Observable = Rx.Observable,
|
38
|
+
AnonymousObservable = Rx.Internals.AnonymousObservable,
|
39
|
+
AsyncSubject = Rx.AsyncSubject,
|
40
|
+
disposableCreate = Rx.Disposable.create,
|
41
|
+
CompositeDisposable= Rx.CompositeDisposable,
|
42
|
+
AsyncSubject = Rx.AsyncSubject
|
43
|
+
timeoutScheduler = Rx.Scheduler.timeout,
|
44
|
+
slice = Array.prototype.slice;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.
|
48
|
+
*
|
49
|
+
* @example
|
50
|
+
* var res = Rx.Observable.start(function () { console.log('hello'); });
|
51
|
+
* var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);
|
52
|
+
* var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);
|
53
|
+
*
|
54
|
+
* @param {Function} func Function to run asynchronously.
|
55
|
+
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
56
|
+
* @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
57
|
+
* @returns {Observable} An observable sequence exposing the function's result value, or an exception.
|
58
|
+
*
|
59
|
+
* Remarks
|
60
|
+
* * The function is called immediately, not during the subscription of the resulting sequence.
|
61
|
+
* * Multiple subscriptions to the resulting sequence can observe the function's result.
|
62
|
+
*/
|
63
|
+
Observable.start = function (func, scheduler, context) {
|
64
|
+
return observableToAsync(func, scheduler, context)();
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
|
69
|
+
*
|
70
|
+
* @example
|
71
|
+
* var res = Rx.Observable.toAsync(function (x, y) { return x + y; })(4, 3);
|
72
|
+
* var res = Rx.Observable.toAsync(function (x, y) { return x + y; }, Rx.Scheduler.timeout)(4, 3);
|
73
|
+
* var res = Rx.Observable.toAsync(function (x) { this.log(x); }, Rx.Scheduler.timeout, console)('hello');
|
74
|
+
*
|
75
|
+
* @param {Function} function Function to convert to an asynchronous function.
|
76
|
+
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
77
|
+
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
78
|
+
* @returns {Function} Asynchronous function.
|
79
|
+
*/
|
80
|
+
var observableToAsync = Observable.toAsync = function (func, scheduler, context) {
|
81
|
+
scheduler || (scheduler = timeoutScheduler);
|
82
|
+
return function () {
|
83
|
+
var args = arguments,
|
84
|
+
subject = new AsyncSubject();
|
85
|
+
|
86
|
+
scheduler.schedule(function () {
|
87
|
+
var result;
|
88
|
+
try {
|
89
|
+
result = func.apply(context, args);
|
90
|
+
} catch (e) {
|
91
|
+
subject.onError(e);
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
subject.onNext(result);
|
95
|
+
subject.onCompleted();
|
96
|
+
});
|
97
|
+
return subject.asObservable();
|
98
|
+
};
|
99
|
+
};
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Converts a callback function to an observable sequence.
|
103
|
+
*
|
104
|
+
* @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
|
105
|
+
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
106
|
+
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
107
|
+
* @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
|
108
|
+
* @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
|
109
|
+
*/
|
110
|
+
Observable.fromCallback = function (func, scheduler, context, selector) {
|
111
|
+
scheduler || (scheduler = timeoutScheduler);
|
112
|
+
return function () {
|
113
|
+
var args = slice.call(arguments, 0),
|
114
|
+
subject = new AsyncSubject();
|
115
|
+
|
116
|
+
scheduler.schedule(function () {
|
117
|
+
function handler(e) {
|
118
|
+
var results = e;
|
119
|
+
|
120
|
+
if (selector) {
|
121
|
+
try {
|
122
|
+
results = selector(arguments);
|
123
|
+
} catch (err) {
|
124
|
+
subject.onError(err);
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
} else {
|
128
|
+
if (results.length === 1) {
|
129
|
+
results = results[0];
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
subject.onNext(results);
|
134
|
+
subject.onCompleted();
|
135
|
+
}
|
136
|
+
|
137
|
+
args.push(handler);
|
138
|
+
func.apply(context, args);
|
139
|
+
});
|
140
|
+
|
141
|
+
return subject.asObservable();
|
142
|
+
};
|
143
|
+
};
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
|
147
|
+
* @param {Function} func The function to call
|
148
|
+
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
149
|
+
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
150
|
+
* @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
|
151
|
+
* @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
|
152
|
+
*/
|
153
|
+
Observable.fromNodeCallback = function (func, scheduler, context, selector) {
|
154
|
+
scheduler || (scheduler = timeoutScheduler);
|
155
|
+
return function () {
|
156
|
+
var args = slice.call(arguments, 0),
|
157
|
+
subject = new AsyncSubject();
|
158
|
+
|
159
|
+
scheduler.schedule(function () {
|
160
|
+
function handler(err) {
|
161
|
+
if (err) {
|
162
|
+
subject.onError(err);
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
166
|
+
var results = slice.call(arguments, 1);
|
167
|
+
|
168
|
+
if (selector) {
|
169
|
+
try {
|
170
|
+
results = selector(results);
|
171
|
+
} catch (e) {
|
172
|
+
subject.onError(e);
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
} else {
|
176
|
+
if (results.length === 1) {
|
177
|
+
results = results[0];
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
subject.onNext(results);
|
182
|
+
subject.onCompleted();
|
183
|
+
}
|
184
|
+
|
185
|
+
args.push(handler);
|
186
|
+
func.apply(context, args);
|
187
|
+
});
|
188
|
+
|
189
|
+
return subject.asObservable();
|
190
|
+
};
|
191
|
+
};
|
192
|
+
|
193
|
+
function createListener (element, name, handler) {
|
194
|
+
// Node.js specific
|
195
|
+
if (element.addListener) {
|
196
|
+
element.addListener(name, handler);
|
197
|
+
return disposableCreate(function () {
|
198
|
+
element.removeListener(name, handler);
|
199
|
+
});
|
200
|
+
} else if (element.addEventListener) {
|
201
|
+
element.addEventListener(name, handler, false);
|
202
|
+
return disposableCreate(function () {
|
203
|
+
element.removeEventListener(name, handler, false);
|
204
|
+
});
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
function createEventListener (el, eventName, handler) {
|
209
|
+
var disposables = new CompositeDisposable();
|
210
|
+
|
211
|
+
// Asume NodeList
|
212
|
+
if (el && el.length) {
|
213
|
+
for (var i = 0, len = el.length; i < len; i++) {
|
214
|
+
disposables.add(createEventListener(el[i], eventName, handler));
|
215
|
+
}
|
216
|
+
} else if (el) {
|
217
|
+
disposables.add(createListener(el, eventName, handler));
|
218
|
+
}
|
219
|
+
|
220
|
+
return disposables;
|
221
|
+
}
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
|
225
|
+
*
|
226
|
+
* @example
|
227
|
+
* var source = Rx.Observable.fromEvent(element, 'mouseup');
|
228
|
+
*
|
229
|
+
* @param {Object} element The DOMElement or NodeList to attach a listener.
|
230
|
+
* @param {String} eventName The event name to attach the observable sequence.
|
231
|
+
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
232
|
+
* @returns {Observable} An observable sequence of events from the specified element and the specified event.
|
233
|
+
*/
|
234
|
+
Observable.fromEvent = function (element, eventName, selector) {
|
235
|
+
return new AnonymousObservable(function (observer) {
|
236
|
+
return createEventListener(
|
237
|
+
element,
|
238
|
+
eventName,
|
239
|
+
function handler (e) {
|
240
|
+
var results = e;
|
241
|
+
|
242
|
+
if (selector) {
|
243
|
+
try {
|
244
|
+
results = selector(arguments);
|
245
|
+
} catch (err) {
|
246
|
+
observer.onError(err);
|
247
|
+
return
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
observer.onNext(results);
|
252
|
+
});
|
253
|
+
}).publish().refCount();
|
254
|
+
};
|
255
|
+
/**
|
256
|
+
* Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
|
257
|
+
* @param {Function} addHandler The function to add a handler to the emitter.
|
258
|
+
* @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
|
259
|
+
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
260
|
+
* @returns {Observable} An observable sequence which wraps an event from an event emitter
|
261
|
+
*/
|
262
|
+
Observable.fromEventPattern = function (addHandler, removeHandler, selector) {
|
263
|
+
return new AnonymousObservable(function (observer) {
|
264
|
+
function innerHandler (e) {
|
265
|
+
var result = e;
|
266
|
+
if (selector) {
|
267
|
+
try {
|
268
|
+
result = selector(arguments);
|
269
|
+
} catch (err) {
|
270
|
+
observer.onError(err);
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
observer.onNext(result);
|
275
|
+
}
|
276
|
+
|
277
|
+
var returnValue = addHandler(innerHandler);
|
278
|
+
return disposableCreate(function () {
|
279
|
+
if (removeHandler) {
|
280
|
+
removeHandler(innerHandler, returnValue);
|
281
|
+
}
|
282
|
+
});
|
283
|
+
}).publish().refCount();
|
284
|
+
};
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Converts a Promise to an Observable sequence
|
288
|
+
* @param {Promise} A Promises A+ implementation instance.
|
289
|
+
* @returns {Observable} An Observable sequence which wraps the existing promise success and failure.
|
290
|
+
*/
|
291
|
+
Observable.fromPromise = function (promise) {
|
292
|
+
var subject = new AsyncSubject();
|
293
|
+
|
294
|
+
promise.then(
|
295
|
+
function (value) {
|
296
|
+
subject.onNext(value);
|
297
|
+
subject.onCompleted();
|
298
|
+
},
|
299
|
+
function (reason) {
|
300
|
+
subject.onError(reason);
|
301
|
+
});
|
302
|
+
|
303
|
+
return subject.asObservable();
|
304
|
+
};
|
305
|
+
return Rx;
|
306
|
+
}));
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){function d(a,b,c){return a.addListener?(a.addListener(b,c),i(function(){a.removeListener(b,c)})):a.addEventListener?(a.addEventListener(b,c,!1),i(function(){a.removeEventListener(b,c,!1)})):void 0}function e(a,b,c){var f=new j;if(a&&a.length)for(var g=0,h=a.length;h>g;g++)f.add(e(a[g],b,c));else a&&f.add(d(a,b,c));return f}var f=c.Observable,g=c.Internals.AnonymousObservable,h=c.AsyncSubject,i=c.Disposable.create,j=c.CompositeDisposable,h=c.AsyncSubject;timeoutScheduler=c.Scheduler.timeout,slice=Array.prototype.slice,f.start=function(a,b,c){return k(a,b,c)()};var k=f.toAsync=function(a,b,c){return b||(b=timeoutScheduler),function(){var d=arguments,e=new h;return b.schedule(function(){var b;try{b=a.apply(c,d)}catch(f){return e.onError(f),void 0}e.onNext(b),e.onCompleted()}),e.asObservable()}};return f.fromCallback=function(a,b,c,d){return b||(b=timeoutScheduler),function(){var e=slice.call(arguments,0),f=new h;return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)}),f.asObservable()}},f.fromNodeCallback=function(a,b,c,d){return b||(b=timeoutScheduler),function(){var e=slice.call(arguments,0),f=new h;return b.schedule(function(){function b(a){if(a)return f.onError(a),void 0;var b=slice.call(arguments,1);if(d)try{b=d(b)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)}),f.asObservable()}},f.fromEvent=function(a,b,c){return new g(function(d){return e(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)})}).publish().refCount()},f.fromEventPattern=function(a,b,c){return new g(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)}var f=a(e);return i(function(){b&&b(e,f)})}).publish().refCount()},f.fromPromise=function(a){var b=new h;return a.then(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)}),b.asObservable()},c});
|