rxjs-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,503 @@
|
|
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
|
+
// Defaults
|
37
|
+
var Observer = Rx.Observer,
|
38
|
+
Observable = Rx.Observable,
|
39
|
+
Notification = Rx.Notification,
|
40
|
+
VirtualTimeScheduler = Rx.VirtualTimeScheduler,
|
41
|
+
Disposable = Rx.Disposable,
|
42
|
+
disposableEmpty = Disposable.empty,
|
43
|
+
disposableCreate = Disposable.create,
|
44
|
+
CompositeDisposable = Rx.CompositeDisposable,
|
45
|
+
SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
|
46
|
+
slice = Array.prototype.slice,
|
47
|
+
inherits = Rx.Internals.inherits,
|
48
|
+
isEqual = Rx.Internals.isEqual;
|
49
|
+
|
50
|
+
// Utilities
|
51
|
+
function defaultComparer(x, y) {
|
52
|
+
return isEqual(x, y);
|
53
|
+
}
|
54
|
+
|
55
|
+
function argsOrArray(args, idx) {
|
56
|
+
return args.length === 1 && Array.isArray(args[idx]) ?
|
57
|
+
args[idx] :
|
58
|
+
slice.call(args);
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @private
|
63
|
+
* @constructor
|
64
|
+
*/
|
65
|
+
function OnNextPredicate(predicate) {
|
66
|
+
this.predicate = predicate;
|
67
|
+
};
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @private
|
71
|
+
* @memberOf OnNextPredicate#
|
72
|
+
*/
|
73
|
+
OnNextPredicate.prototype.equals = function (other) {
|
74
|
+
if (other === this) { return true; }
|
75
|
+
if (other == null) { return false; }
|
76
|
+
if (other.kind !== 'N') { return false; }
|
77
|
+
return this.predicate(other.value);
|
78
|
+
};
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @private
|
82
|
+
* @constructor
|
83
|
+
*/
|
84
|
+
function OnErrorPredicate(predicate) {
|
85
|
+
this.predicate = predicate;
|
86
|
+
};
|
87
|
+
|
88
|
+
/**
|
89
|
+
* @private
|
90
|
+
* @memberOf OnErrorPredicate#
|
91
|
+
*/
|
92
|
+
OnErrorPredicate.prototype.equals = function (other) {
|
93
|
+
if (other === this) { return true; }
|
94
|
+
if (other == null) { return false; }
|
95
|
+
if (other.kind !== 'E') { return false; }
|
96
|
+
return this.predicate(other.exception);
|
97
|
+
};
|
98
|
+
|
99
|
+
/**
|
100
|
+
* @static
|
101
|
+
* type Object
|
102
|
+
*/
|
103
|
+
var ReactiveTest = Rx.ReactiveTest = {
|
104
|
+
/** Default virtual time used for creation of observable sequences in unit tests. */
|
105
|
+
created: 100,
|
106
|
+
/** Default virtual time used to subscribe to observable sequences in unit tests. */
|
107
|
+
subscribed: 200,
|
108
|
+
/** Default virtual time used to dispose subscriptions in unit tests. */
|
109
|
+
disposed: 1000,
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Factory method for an OnNext notification record at a given time with a given value or a predicate function.
|
113
|
+
*
|
114
|
+
* 1 - ReactiveTest.onNext(200, 42);
|
115
|
+
* 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; });
|
116
|
+
*
|
117
|
+
* @param ticks Recorded virtual time the OnNext notification occurs.
|
118
|
+
* @param value Recorded value stored in the OnNext notification or a predicate.
|
119
|
+
* @return Recorded OnNext notification.
|
120
|
+
*/
|
121
|
+
onNext: function (ticks, value) {
|
122
|
+
if (typeof value === 'function') {
|
123
|
+
return new Recorded(ticks, new OnNextPredicate(value));
|
124
|
+
}
|
125
|
+
return new Recorded(ticks, Notification.createOnNext(value));
|
126
|
+
},
|
127
|
+
/**
|
128
|
+
* Factory method for an OnError notification record at a given time with a given error.
|
129
|
+
*
|
130
|
+
* 1 - ReactiveTest.onNext(200, new Error('error'));
|
131
|
+
* 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; });
|
132
|
+
*
|
133
|
+
* @param ticks Recorded virtual time the OnError notification occurs.
|
134
|
+
* @param exception Recorded exception stored in the OnError notification.
|
135
|
+
* @return Recorded OnError notification.
|
136
|
+
*/
|
137
|
+
onError: function (ticks, exception) {
|
138
|
+
if (typeof exception === 'function') {
|
139
|
+
return new Recorded(ticks, new OnErrorPredicate(exception));
|
140
|
+
}
|
141
|
+
return new Recorded(ticks, Notification.createOnError(exception));
|
142
|
+
},
|
143
|
+
/**
|
144
|
+
* Factory method for an OnCompleted notification record at a given time.
|
145
|
+
*
|
146
|
+
* @param ticks Recorded virtual time the OnCompleted notification occurs.
|
147
|
+
* @return Recorded OnCompleted notification.
|
148
|
+
*/
|
149
|
+
onCompleted: function (ticks) {
|
150
|
+
return new Recorded(ticks, Notification.createOnCompleted());
|
151
|
+
},
|
152
|
+
/**
|
153
|
+
* Factory method for a subscription record based on a given subscription and disposal time.
|
154
|
+
*
|
155
|
+
* @param start Virtual time indicating when the subscription was created.
|
156
|
+
* @param end Virtual time indicating when the subscription was disposed.
|
157
|
+
* @return Subscription object.
|
158
|
+
*/
|
159
|
+
subscribe: function (start, end) {
|
160
|
+
return new Subscription(start, end);
|
161
|
+
}
|
162
|
+
};
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Creates a new object recording the production of the specified value at the given virtual time.
|
166
|
+
*
|
167
|
+
* @constructor
|
168
|
+
* @param {Number} time Virtual time the value was produced on.
|
169
|
+
* @param {Mixed} value Value that was produced.
|
170
|
+
* @param {Function} comparer An optional comparer.
|
171
|
+
*/
|
172
|
+
var Recorded = Rx.Recorded = function (time, value, comparer) {
|
173
|
+
this.time = time;
|
174
|
+
this.value = value;
|
175
|
+
this.comparer = comparer || defaultComparer;
|
176
|
+
};
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Checks whether the given recorded object is equal to the current instance.
|
180
|
+
*
|
181
|
+
* @param {Recorded} other Recorded object to check for equality.
|
182
|
+
* @returns {Boolean} true if both objects are equal; false otherwise.
|
183
|
+
*/
|
184
|
+
Recorded.prototype.equals = function (other) {
|
185
|
+
return this.time === other.time && this.comparer(this.value, other.value);
|
186
|
+
};
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Returns a string representation of the current Recorded value.
|
190
|
+
*
|
191
|
+
* @returns {String} String representation of the current Recorded value.
|
192
|
+
*/
|
193
|
+
Recorded.prototype.toString = function () {
|
194
|
+
return this.value.toString() + '@' + this.time;
|
195
|
+
};
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Creates a new subscription object with the given virtual subscription and unsubscription time.
|
199
|
+
*
|
200
|
+
* @constructor
|
201
|
+
* @param {Number} subscribe Virtual time at which the subscription occurred.
|
202
|
+
* @param {Number} unsubscribe Virtual time at which the unsubscription occurred.
|
203
|
+
*/
|
204
|
+
var Subscription = Rx.Subscription = function (start, end) {
|
205
|
+
this.subscribe = start;
|
206
|
+
this.unsubscribe = end || Number.MAX_VALUE;
|
207
|
+
};
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Checks whether the given subscription is equal to the current instance.
|
211
|
+
* @param other Subscription object to check for equality.
|
212
|
+
* @returns {Boolean} true if both objects are equal; false otherwise.
|
213
|
+
*/
|
214
|
+
Subscription.prototype.equals = function (other) {
|
215
|
+
return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe;
|
216
|
+
};
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Returns a string representation of the current Subscription value.
|
220
|
+
* @returns {String} String representation of the current Subscription value.
|
221
|
+
*/
|
222
|
+
Subscription.prototype.toString = function () {
|
223
|
+
return '(' + this.subscribe + ', ' + this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe + ')';
|
224
|
+
};
|
225
|
+
|
226
|
+
/** @private */
|
227
|
+
var MockDisposable = Rx.MockDisposable = function (scheduler) {
|
228
|
+
this.scheduler = scheduler;
|
229
|
+
this.disposes = [];
|
230
|
+
this.disposes.push(this.scheduler.clock);
|
231
|
+
};
|
232
|
+
|
233
|
+
/*
|
234
|
+
* @memberOf MockDisposable#
|
235
|
+
* @prviate
|
236
|
+
*/
|
237
|
+
MockDisposable.prototype.dispose = function () {
|
238
|
+
this.disposes.push(this.scheduler.clock);
|
239
|
+
};
|
240
|
+
|
241
|
+
/** @private */
|
242
|
+
var MockObserver = (function (_super) {
|
243
|
+
inherits(MockObserver, _super);
|
244
|
+
|
245
|
+
/*
|
246
|
+
* @constructor
|
247
|
+
* @prviate
|
248
|
+
*/
|
249
|
+
function MockObserver(scheduler) {
|
250
|
+
_super.call(this);
|
251
|
+
this.scheduler = scheduler;
|
252
|
+
this.messages = [];
|
253
|
+
}
|
254
|
+
|
255
|
+
var MockObserverPrototype = MockObserver.prototype;
|
256
|
+
|
257
|
+
/*
|
258
|
+
* @memberOf MockObserverPrototype#
|
259
|
+
* @prviate
|
260
|
+
*/
|
261
|
+
MockObserverPrototype.onNext = function (value) {
|
262
|
+
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value)));
|
263
|
+
};
|
264
|
+
|
265
|
+
/*
|
266
|
+
* @memberOf MockObserverPrototype#
|
267
|
+
* @prviate
|
268
|
+
*/
|
269
|
+
MockObserverPrototype.onError = function (exception) {
|
270
|
+
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(exception)));
|
271
|
+
};
|
272
|
+
|
273
|
+
/*
|
274
|
+
* @memberOf MockObserverPrototype#
|
275
|
+
* @prviate
|
276
|
+
*/
|
277
|
+
MockObserverPrototype.onCompleted = function () {
|
278
|
+
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted()));
|
279
|
+
};
|
280
|
+
|
281
|
+
return MockObserver;
|
282
|
+
})(Observer);
|
283
|
+
|
284
|
+
/** @private */
|
285
|
+
var HotObservable = (function (_super) {
|
286
|
+
|
287
|
+
function subscribe(observer) {
|
288
|
+
var observable = this;
|
289
|
+
this.observers.push(observer);
|
290
|
+
this.subscriptions.push(new Subscription(this.scheduler.clock));
|
291
|
+
var index = this.subscriptions.length - 1;
|
292
|
+
return disposableCreate(function () {
|
293
|
+
var idx = observable.observers.indexOf(observer);
|
294
|
+
observable.observers.splice(idx, 1);
|
295
|
+
observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);
|
296
|
+
});
|
297
|
+
}
|
298
|
+
|
299
|
+
inherits(HotObservable, _super);
|
300
|
+
|
301
|
+
/**
|
302
|
+
* @private
|
303
|
+
* @constructor
|
304
|
+
*/
|
305
|
+
function HotObservable(scheduler, messages) {
|
306
|
+
_super.call(this, subscribe);
|
307
|
+
var message, notification, observable = this;
|
308
|
+
this.scheduler = scheduler;
|
309
|
+
this.messages = messages;
|
310
|
+
this.subscriptions = [];
|
311
|
+
this.observers = [];
|
312
|
+
for (var i = 0, len = this.messages.length; i < len; i++) {
|
313
|
+
message = this.messages[i];
|
314
|
+
notification = message.value;
|
315
|
+
(function (innerNotification) {
|
316
|
+
scheduler.scheduleAbsoluteWithState(null, message.time, function () {
|
317
|
+
for (var j = 0; j < observable.observers.length; j++) {
|
318
|
+
innerNotification.accept(observable.observers[j]);
|
319
|
+
}
|
320
|
+
return disposableEmpty;
|
321
|
+
});
|
322
|
+
})(notification);
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
return HotObservable;
|
327
|
+
})(Observable);
|
328
|
+
|
329
|
+
/** @private */
|
330
|
+
var ColdObservable = (function (_super) {
|
331
|
+
|
332
|
+
function subscribe(observer) {
|
333
|
+
var message, notification, observable = this;
|
334
|
+
this.subscriptions.push(new Subscription(this.scheduler.clock));
|
335
|
+
var index = this.subscriptions.length - 1;
|
336
|
+
var d = new CompositeDisposable();
|
337
|
+
for (var i = 0, len = this.messages.length; i < len; i++) {
|
338
|
+
message = this.messages[i];
|
339
|
+
notification = message.value;
|
340
|
+
(function (innerNotification) {
|
341
|
+
d.add(observable.scheduler.scheduleRelativeWithState(null, message.time, function () {
|
342
|
+
innerNotification.accept(observer);
|
343
|
+
return disposableEmpty;
|
344
|
+
}));
|
345
|
+
})(notification);
|
346
|
+
}
|
347
|
+
return disposableCreate(function () {
|
348
|
+
observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);
|
349
|
+
d.dispose();
|
350
|
+
});
|
351
|
+
}
|
352
|
+
|
353
|
+
inherits(ColdObservable, _super);
|
354
|
+
|
355
|
+
/**
|
356
|
+
* @private
|
357
|
+
* @constructor
|
358
|
+
*/
|
359
|
+
function ColdObservable(scheduler, messages) {
|
360
|
+
_super.call(this, subscribe);
|
361
|
+
this.scheduler = scheduler;
|
362
|
+
this.messages = messages;
|
363
|
+
this.subscriptions = [];
|
364
|
+
}
|
365
|
+
|
366
|
+
return ColdObservable;
|
367
|
+
})(Observable);
|
368
|
+
|
369
|
+
/** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */
|
370
|
+
Rx.TestScheduler = (function (_super) {
|
371
|
+
inherits(TestScheduler, _super);
|
372
|
+
|
373
|
+
function baseComparer(x, y) {
|
374
|
+
return x > y ? 1 : (x < y ? -1 : 0);
|
375
|
+
}
|
376
|
+
|
377
|
+
/** @constructor */
|
378
|
+
function TestScheduler() {
|
379
|
+
_super.call(this, 0, baseComparer);
|
380
|
+
}
|
381
|
+
|
382
|
+
/**
|
383
|
+
* Schedules an action to be executed at the specified virtual time.
|
384
|
+
*
|
385
|
+
* @param state State passed to the action to be executed.
|
386
|
+
* @param dueTime Absolute virtual time at which to execute the action.
|
387
|
+
* @param action Action to be executed.
|
388
|
+
* @return Disposable object used to cancel the scheduled action (best effort).
|
389
|
+
*/
|
390
|
+
TestScheduler.prototype.scheduleAbsoluteWithState = function (state, dueTime, action) {
|
391
|
+
if (dueTime <= this.clock) {
|
392
|
+
dueTime = this.clock + 1;
|
393
|
+
}
|
394
|
+
return _super.prototype.scheduleAbsoluteWithState.call(this, state, dueTime, action);
|
395
|
+
};
|
396
|
+
/**
|
397
|
+
* Adds a relative virtual time to an absolute virtual time value.
|
398
|
+
*
|
399
|
+
* @param absolute Absolute virtual time value.
|
400
|
+
* @param relative Relative virtual time value to add.
|
401
|
+
* @return Resulting absolute virtual time sum value.
|
402
|
+
*/
|
403
|
+
TestScheduler.prototype.add = function (absolute, relative) {
|
404
|
+
return absolute + relative;
|
405
|
+
};
|
406
|
+
/**
|
407
|
+
* Converts the absolute virtual time value to a DateTimeOffset value.
|
408
|
+
*
|
409
|
+
* @param absolute Absolute virtual time value to convert.
|
410
|
+
* @return Corresponding DateTimeOffset value.
|
411
|
+
*/
|
412
|
+
TestScheduler.prototype.toDateTimeOffset = function (absolute) {
|
413
|
+
return new Date(absolute).getTime();
|
414
|
+
};
|
415
|
+
/**
|
416
|
+
* Converts the TimeSpan value to a relative virtual time value.
|
417
|
+
*
|
418
|
+
* @param timeSpan TimeSpan value to convert.
|
419
|
+
* @return Corresponding relative virtual time value.
|
420
|
+
*/
|
421
|
+
TestScheduler.prototype.toRelative = function (timeSpan) {
|
422
|
+
return timeSpan;
|
423
|
+
};
|
424
|
+
/**
|
425
|
+
* Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription.
|
426
|
+
*
|
427
|
+
* @param create Factory method to create an observable sequence.
|
428
|
+
* @param created Virtual time at which to invoke the factory to create an observable sequence.
|
429
|
+
* @param subscribed Virtual time at which to subscribe to the created observable sequence.
|
430
|
+
* @param disposed Virtual time at which to dispose the subscription.
|
431
|
+
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
|
432
|
+
*/
|
433
|
+
TestScheduler.prototype.startWithTiming = function (create, created, subscribed, disposed) {
|
434
|
+
var observer = this.createObserver(), source, subscription;
|
435
|
+
this.scheduleAbsoluteWithState(null, created, function () {
|
436
|
+
source = create();
|
437
|
+
return disposableEmpty;
|
438
|
+
});
|
439
|
+
this.scheduleAbsoluteWithState(null, subscribed, function () {
|
440
|
+
subscription = source.subscribe(observer);
|
441
|
+
return disposableEmpty;
|
442
|
+
});
|
443
|
+
this.scheduleAbsoluteWithState(null, disposed, function () {
|
444
|
+
subscription.dispose();
|
445
|
+
return disposableEmpty;
|
446
|
+
});
|
447
|
+
this.start();
|
448
|
+
return observer;
|
449
|
+
};
|
450
|
+
/**
|
451
|
+
* Starts the test scheduler and uses the specified virtual time to dispose the subscription to the sequence obtained through the factory function.
|
452
|
+
* Default virtual times are used for factory invocation and sequence subscription.
|
453
|
+
*
|
454
|
+
* @param create Factory method to create an observable sequence.
|
455
|
+
* @param disposed Virtual time at which to dispose the subscription.
|
456
|
+
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
|
457
|
+
*/
|
458
|
+
TestScheduler.prototype.startWithDispose = function (create, disposed) {
|
459
|
+
return this.startWithTiming(create, ReactiveTest.created, ReactiveTest.subscribed, disposed);
|
460
|
+
};
|
461
|
+
/**
|
462
|
+
* Starts the test scheduler and uses default virtual times to invoke the factory function, to subscribe to the resulting sequence, and to dispose the subscription.
|
463
|
+
*
|
464
|
+
* @param create Factory method to create an observable sequence.
|
465
|
+
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
|
466
|
+
*/
|
467
|
+
TestScheduler.prototype.startWithCreate = function (create) {
|
468
|
+
return this.startWithTiming(create, ReactiveTest.created, ReactiveTest.subscribed, ReactiveTest.disposed);
|
469
|
+
};
|
470
|
+
/**
|
471
|
+
* Creates a hot observable using the specified timestamped notification messages either as an array or arguments.
|
472
|
+
*
|
473
|
+
* @param messages Notifications to surface through the created sequence at their specified absolute virtual times.
|
474
|
+
* @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications.
|
475
|
+
*/
|
476
|
+
TestScheduler.prototype.createHotObservable = function () {
|
477
|
+
var messages = argsOrArray(arguments, 0);
|
478
|
+
return new HotObservable(this, messages);
|
479
|
+
};
|
480
|
+
/**
|
481
|
+
* Creates a cold observable using the specified timestamped notification messages either as an array or arguments.
|
482
|
+
*
|
483
|
+
* @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time.
|
484
|
+
* @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications.
|
485
|
+
*/
|
486
|
+
TestScheduler.prototype.createColdObservable = function () {
|
487
|
+
var messages = argsOrArray(arguments, 0);
|
488
|
+
return new ColdObservable(this, messages);
|
489
|
+
};
|
490
|
+
/**
|
491
|
+
* Creates an observer that records received notification messages and timestamps those.
|
492
|
+
*
|
493
|
+
* @return Observer that can be used to assert the timing of received notifications.
|
494
|
+
*/
|
495
|
+
TestScheduler.prototype.createObserver = function () {
|
496
|
+
return new MockObserver(this);
|
497
|
+
};
|
498
|
+
|
499
|
+
return TestScheduler;
|
500
|
+
})(VirtualTimeScheduler);
|
501
|
+
|
502
|
+
return Rx;
|
503
|
+
}));
|
@@ -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){return r(a,b)}function e(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:p.call(a)}function f(a){this.predicate=a}function g(a){this.predicate=a}var h=c.Observer,i=c.Observable,j=c.Notification,k=c.VirtualTimeScheduler,l=c.Disposable,m=l.empty,n=l.create,o=c.CompositeDisposable,p=(c.SingleAssignmentDisposable,Array.prototype.slice),q=c.Internals.inherits,r=c.Internals.isEqual;f.prototype.equals=function(a){return a===this?!0:null==a?!1:"N"!==a.kind?!1:this.predicate(a.value)},g.prototype.equals=function(a){return a===this?!0:null==a?!1:"E"!==a.kind?!1:this.predicate(a.exception)};var s=c.ReactiveTest={created:100,subscribed:200,disposed:1e3,onNext:function(a,b){return"function"==typeof b?new t(a,new f(b)):new t(a,j.createOnNext(b))},onError:function(a,b){return"function"==typeof b?new t(a,new g(b)):new t(a,j.createOnError(b))},onCompleted:function(a){return new t(a,j.createOnCompleted())},subscribe:function(a,b){return new u(a,b)}},t=c.Recorded=function(a,b,c){this.time=a,this.value=b,this.comparer=c||d};t.prototype.equals=function(a){return this.time===a.time&&this.comparer(this.value,a.value)},t.prototype.toString=function(){return this.value.toString()+"@"+this.time};var u=c.Subscription=function(a,b){this.subscribe=a,this.unsubscribe=b||Number.MAX_VALUE};u.prototype.equals=function(a){return this.subscribe===a.subscribe&&this.unsubscribe===a.unsubscribe},u.prototype.toString=function(){return"("+this.subscribe+", "+this.unsubscribe===Number.MAX_VALUE?"Infinite":this.unsubscribe+")"};var v=c.MockDisposable=function(a){this.scheduler=a,this.disposes=[],this.disposes.push(this.scheduler.clock)};v.prototype.dispose=function(){this.disposes.push(this.scheduler.clock)};var w=function(a){function b(b){a.call(this),this.scheduler=b,this.messages=[]}q(b,a);var c=b.prototype;return c.onNext=function(a){this.messages.push(new t(this.scheduler.clock,j.createOnNext(a)))},c.onError=function(a){this.messages.push(new t(this.scheduler.clock,j.createOnError(a)))},c.onCompleted=function(){this.messages.push(new t(this.scheduler.clock,j.createOnCompleted()))},b}(h),x=function(a){function b(a){var b=this;this.observers.push(a),this.subscriptions.push(new u(this.scheduler.clock));var c=this.subscriptions.length-1;return n(function(){var d=b.observers.indexOf(a);b.observers.splice(d,1),b.subscriptions[c]=new u(b.subscriptions[c].subscribe,b.scheduler.clock)})}function c(c,d){a.call(this,b);var e,f,g=this;this.scheduler=c,this.messages=d,this.subscriptions=[],this.observers=[];for(var h=0,i=this.messages.length;i>h;h++)e=this.messages[h],f=e.value,function(a){c.scheduleAbsoluteWithState(null,e.time,function(){for(var b=0;b<g.observers.length;b++)a.accept(g.observers[b]);return m})}(f)}return q(c,a),c}(i),y=function(a){function b(a){var b,c,d=this;this.subscriptions.push(new u(this.scheduler.clock));for(var e=this.subscriptions.length-1,f=new o,g=0,h=this.messages.length;h>g;g++)b=this.messages[g],c=b.value,function(c){f.add(d.scheduler.scheduleRelativeWithState(null,b.time,function(){return c.accept(a),m}))}(c);return n(function(){d.subscriptions[e]=new u(d.subscriptions[e].subscribe,d.scheduler.clock),f.dispose()})}function c(c,d){a.call(this,b),this.scheduler=c,this.messages=d,this.subscriptions=[]}return q(c,a),c}(i);return c.TestScheduler=function(a){function b(a,b){return a>b?1:b>a?-1:0}function c(){a.call(this,0,b)}return q(c,a),c.prototype.scheduleAbsoluteWithState=function(b,c,d){return c<=this.clock&&(c=this.clock+1),a.prototype.scheduleAbsoluteWithState.call(this,b,c,d)},c.prototype.add=function(a,b){return a+b},c.prototype.toDateTimeOffset=function(a){return new Date(a).getTime()},c.prototype.toRelative=function(a){return a},c.prototype.startWithTiming=function(a,b,c,d){var e,f,g=this.createObserver();return this.scheduleAbsoluteWithState(null,b,function(){return e=a(),m}),this.scheduleAbsoluteWithState(null,c,function(){return f=e.subscribe(g),m}),this.scheduleAbsoluteWithState(null,d,function(){return f.dispose(),m}),this.start(),g},c.prototype.startWithDispose=function(a,b){return this.startWithTiming(a,s.created,s.subscribed,b)},c.prototype.startWithCreate=function(a){return this.startWithTiming(a,s.created,s.subscribed,s.disposed)},c.prototype.createHotObservable=function(){var a=e(arguments,0);return new x(this,a)},c.prototype.createColdObservable=function(){var a=e(arguments,0);return new y(this,a)},c.prototype.createObserver=function(){return new w(this)},c}(k),c});
|