rxjs-rails 2.2.20 → 2.2.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +38 -20
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +9288 -0
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +3 -0
  7. data/vendor/assets/javascripts/rx.all.js +9102 -0
  8. data/vendor/assets/javascripts/rx.all.min.js +3 -0
  9. data/vendor/assets/javascripts/rx.async.compat.js +5 -4
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +5 -4
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +24 -12
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.binding.js +85 -85
  16. data/vendor/assets/javascripts/rx.coincidence.js +59 -15
  17. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
  18. data/vendor/assets/javascripts/rx.compat.js +809 -742
  19. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  20. data/vendor/assets/javascripts/rx.core.compat.js +2629 -0
  21. data/vendor/assets/javascripts/rx.core.compat.min.js +1 -0
  22. data/vendor/assets/javascripts/rx.core.js +2511 -0
  23. data/vendor/assets/javascripts/rx.core.min.js +1 -0
  24. data/vendor/assets/javascripts/rx.experimental.js +43 -43
  25. data/vendor/assets/javascripts/rx.joinpatterns.js +281 -281
  26. data/vendor/assets/javascripts/rx.js +792 -725
  27. data/vendor/assets/javascripts/rx.lite.compat.js +890 -758
  28. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  29. data/vendor/assets/javascripts/rx.lite.extras.js +664 -0
  30. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -0
  31. data/vendor/assets/javascripts/rx.lite.js +890 -758
  32. data/vendor/assets/javascripts/rx.lite.min.js +2 -2
  33. data/vendor/assets/javascripts/rx.min.js +2 -2
  34. data/vendor/assets/javascripts/rx.testing.js +166 -166
  35. data/vendor/assets/javascripts/rx.testing.min.js +1 -1
  36. data/vendor/assets/javascripts/rx.time.js +132 -131
  37. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  38. data/vendor/assets/javascripts/rx.virtualtime.js +2 -2
  39. metadata +13 -4
  40. data/vendor/assets/javascripts/rx.node.js +0 -142
@@ -0,0 +1,664 @@
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
+ // References
37
+ var Observable = Rx.Observable,
38
+ observableProto = Observable.prototype,
39
+ observableNever = Observable.never,
40
+ observableThrow = Observable.throwException,
41
+ AnonymousObservable = Rx.AnonymousObservable,
42
+ Observer = Rx.Observer,
43
+ Subject = Rx.Subject,
44
+ internals = Rx.internals,
45
+ helpers = Rx.helpers,
46
+ ScheduledObserver = internals.ScheduledObserver,
47
+ SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
48
+ CompositeDisposable = Rx.CompositeDisposable,
49
+ RefCountDisposable = Rx.RefCountDisposable,
50
+ disposableEmpty = Rx.Disposable.empty,
51
+ immediateScheduler = Rx.Scheduler.immediate,
52
+ defaultKeySerializer = helpers.defaultKeySerializer,
53
+ addRef = Rx.internals.addRef,
54
+ identity = helpers.identity,
55
+ isPromise = helpers.isPromise,
56
+ inherits = internals.inherits,
57
+ noop = helpers.noop,
58
+ observableFromPromise = Observable.fromPromise,
59
+ slice = Array.prototype.slice;
60
+
61
+ function argsOrArray(args, idx) {
62
+ return args.length === 1 && Array.isArray(args[idx]) ?
63
+ args[idx] :
64
+ slice.call(args);
65
+ }
66
+
67
+ var argumentOutOfRange = 'Argument out of range';
68
+
69
+ function ScheduledDisposable(scheduler, disposable) {
70
+ this.scheduler = scheduler;
71
+ this.disposable = disposable;
72
+ this.isDisposed = false;
73
+ }
74
+
75
+ ScheduledDisposable.prototype.dispose = function () {
76
+ var parent = this;
77
+ this.scheduler.schedule(function () {
78
+ if (!parent.isDisposed) {
79
+ parent.isDisposed = true;
80
+ parent.disposable.dispose();
81
+ }
82
+ });
83
+ };
84
+
85
+ var CheckedObserver = (function (_super) {
86
+ inherits(CheckedObserver, _super);
87
+
88
+ function CheckedObserver(observer) {
89
+ _super.call(this);
90
+ this._observer = observer;
91
+ this._state = 0; // 0 - idle, 1 - busy, 2 - done
92
+ }
93
+
94
+ var CheckedObserverPrototype = CheckedObserver.prototype;
95
+
96
+ CheckedObserverPrototype.onNext = function (value) {
97
+ this.checkAccess();
98
+ try {
99
+ this._observer.onNext(value);
100
+ } catch (e) {
101
+ throw e;
102
+ } finally {
103
+ this._state = 0;
104
+ }
105
+ };
106
+
107
+ CheckedObserverPrototype.onError = function (err) {
108
+ this.checkAccess();
109
+ try {
110
+ this._observer.onError(err);
111
+ } catch (e) {
112
+ throw e;
113
+ } finally {
114
+ this._state = 2;
115
+ }
116
+ };
117
+
118
+ CheckedObserverPrototype.onCompleted = function () {
119
+ this.checkAccess();
120
+ try {
121
+ this._observer.onCompleted();
122
+ } catch (e) {
123
+ throw e;
124
+ } finally {
125
+ this._state = 2;
126
+ }
127
+ };
128
+
129
+ CheckedObserverPrototype.checkAccess = function () {
130
+ if (this._state === 1) { throw new Error('Re-entrancy detected'); }
131
+ if (this._state === 2) { throw new Error('Observer completed'); }
132
+ if (this._state === 0) { this._state = 1; }
133
+ };
134
+
135
+ return CheckedObserver;
136
+ }(Observer));
137
+
138
+ /** @private */
139
+ var ObserveOnObserver = (function (_super) {
140
+ inherits(ObserveOnObserver, _super);
141
+
142
+ /** @private */
143
+ function ObserveOnObserver() {
144
+ _super.apply(this, arguments);
145
+ }
146
+
147
+ /** @private */
148
+ ObserveOnObserver.prototype.next = function (value) {
149
+ _super.prototype.next.call(this, value);
150
+ this.ensureActive();
151
+ };
152
+
153
+ /** @private */
154
+ ObserveOnObserver.prototype.error = function (e) {
155
+ _super.prototype.error.call(this, e);
156
+ this.ensureActive();
157
+ };
158
+
159
+ /** @private */
160
+ ObserveOnObserver.prototype.completed = function () {
161
+ _super.prototype.completed.call(this);
162
+ this.ensureActive();
163
+ };
164
+
165
+ return ObserveOnObserver;
166
+ })(ScheduledObserver);
167
+
168
+ /**
169
+ * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
170
+ *
171
+ * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
172
+ * that require to be run on a scheduler, use subscribeOn.
173
+ *
174
+ * @param {Scheduler} scheduler Scheduler to notify observers on.
175
+ * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
176
+ */
177
+ observableProto.observeOn = function (scheduler) {
178
+ var source = this;
179
+ return new AnonymousObservable(function (observer) {
180
+ return source.subscribe(new ObserveOnObserver(scheduler, observer));
181
+ });
182
+ };
183
+
184
+ /**
185
+ * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
186
+ * see the remarks section for more information on the distinction between subscribeOn and observeOn.
187
+
188
+ * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
189
+ * callbacks on a scheduler, use observeOn.
190
+
191
+ * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.
192
+ * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
193
+ */
194
+ observableProto.subscribeOn = function (scheduler) {
195
+ var source = this;
196
+ return new AnonymousObservable(function (observer) {
197
+ var m = new SingleAssignmentDisposable(), d = new SerialDisposable();
198
+ d.setDisposable(m);
199
+ m.setDisposable(scheduler.schedule(function () {
200
+ d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));
201
+ }));
202
+ return d;
203
+ });
204
+ };
205
+
206
+ /**
207
+ * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
208
+ *
209
+ * @example
210
+ * var res = Rx.Observable.using(function () { return new AsyncSubject(); }, function (s) { return s; });
211
+ * @param {Function} resourceFactory Factory function to obtain a resource object.
212
+ * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.
213
+ * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.
214
+ */
215
+ Observable.using = function (resourceFactory, observableFactory) {
216
+ return new AnonymousObservable(function (observer) {
217
+ var disposable = disposableEmpty, resource, source;
218
+ try {
219
+ resource = resourceFactory();
220
+ if (resource) {
221
+ disposable = resource;
222
+ }
223
+ source = observableFactory(resource);
224
+ } catch (exception) {
225
+ return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);
226
+ }
227
+ return new CompositeDisposable(source.subscribe(observer), disposable);
228
+ });
229
+ };
230
+
231
+ /**
232
+ * Propagates the observable sequence or Promise that reacts first.
233
+ * @param {Observable} rightSource Second observable sequence or Promise.
234
+ * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.
235
+ */
236
+ observableProto.amb = function (rightSource) {
237
+ var leftSource = this;
238
+ return new AnonymousObservable(function (observer) {
239
+ var choice,
240
+ leftChoice = 'L', rightChoice = 'R',
241
+ leftSubscription = new SingleAssignmentDisposable(),
242
+ rightSubscription = new SingleAssignmentDisposable();
243
+
244
+ isPromise(rightSource) && (rightSource = observableFromPromise(rightSource));
245
+
246
+ function choiceL() {
247
+ if (!choice) {
248
+ choice = leftChoice;
249
+ rightSubscription.dispose();
250
+ }
251
+ }
252
+
253
+ function choiceR() {
254
+ if (!choice) {
255
+ choice = rightChoice;
256
+ leftSubscription.dispose();
257
+ }
258
+ }
259
+
260
+ leftSubscription.setDisposable(leftSource.subscribe(function (left) {
261
+ choiceL();
262
+ if (choice === leftChoice) {
263
+ observer.onNext(left);
264
+ }
265
+ }, function (err) {
266
+ choiceL();
267
+ if (choice === leftChoice) {
268
+ observer.onError(err);
269
+ }
270
+ }, function () {
271
+ choiceL();
272
+ if (choice === leftChoice) {
273
+ observer.onCompleted();
274
+ }
275
+ }));
276
+
277
+ rightSubscription.setDisposable(rightSource.subscribe(function (right) {
278
+ choiceR();
279
+ if (choice === rightChoice) {
280
+ observer.onNext(right);
281
+ }
282
+ }, function (err) {
283
+ choiceR();
284
+ if (choice === rightChoice) {
285
+ observer.onError(err);
286
+ }
287
+ }, function () {
288
+ choiceR();
289
+ if (choice === rightChoice) {
290
+ observer.onCompleted();
291
+ }
292
+ }));
293
+
294
+ return new CompositeDisposable(leftSubscription, rightSubscription);
295
+ });
296
+ };
297
+
298
+ /**
299
+ * Propagates the observable sequence or Promise that reacts first.
300
+ *
301
+ * @example
302
+ * var = Rx.Observable.amb(xs, ys, zs);
303
+ * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
304
+ */
305
+ Observable.amb = function () {
306
+ var acc = observableNever(),
307
+ items = argsOrArray(arguments, 0);
308
+ function func(previous, current) {
309
+ return previous.amb(current);
310
+ }
311
+ for (var i = 0, len = items.length; i < len; i++) {
312
+ acc = func(acc, items[i]);
313
+ }
314
+ return acc;
315
+ };
316
+
317
+ /**
318
+ * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
319
+ * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.
320
+ * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.
321
+ */
322
+ observableProto.onErrorResumeNext = function (second) {
323
+ if (!second) {
324
+ throw new Error('Second observable is required');
325
+ }
326
+ return onErrorResumeNext([this, second]);
327
+ };
328
+
329
+ /**
330
+ * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
331
+ *
332
+ * @example
333
+ * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
334
+ * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
335
+ * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
336
+ */
337
+ var onErrorResumeNext = Observable.onErrorResumeNext = function () {
338
+ var sources = argsOrArray(arguments, 0);
339
+ return new AnonymousObservable(function (observer) {
340
+ var pos = 0, subscription = new SerialDisposable(),
341
+ cancelable = immediateScheduler.scheduleRecursive(function (self) {
342
+ var current, d;
343
+ if (pos < sources.length) {
344
+ current = sources[pos++];
345
+ isPromise(current) && (current = observableFromPromise(current));
346
+ d = new SingleAssignmentDisposable();
347
+ subscription.setDisposable(d);
348
+ d.setDisposable(current.subscribe(observer.onNext.bind(observer), function () {
349
+ self();
350
+ }, function () {
351
+ self();
352
+ }));
353
+ } else {
354
+ observer.onCompleted();
355
+ }
356
+ });
357
+ return new CompositeDisposable(subscription, cancelable);
358
+ });
359
+ };
360
+
361
+ /**
362
+ * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
363
+ *
364
+ * @example
365
+ * var res = xs.bufferWithCount(10);
366
+ * var res = xs.bufferWithCount(10, 1);
367
+ * @param {Number} count Length of each buffer.
368
+ * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.
369
+ * @returns {Observable} An observable sequence of buffers.
370
+ */
371
+ observableProto.bufferWithCount = function (count, skip) {
372
+ if (typeof skip !== 'number') {
373
+ skip = count;
374
+ }
375
+ return this.windowWithCount(count, skip).selectMany(function (x) {
376
+ return x.toArray();
377
+ }).where(function (x) {
378
+ return x.length > 0;
379
+ });
380
+ };
381
+
382
+ /**
383
+ * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
384
+ *
385
+ * var res = xs.windowWithCount(10);
386
+ * var res = xs.windowWithCount(10, 1);
387
+ * @param {Number} count Length of each window.
388
+ * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.
389
+ * @returns {Observable} An observable sequence of windows.
390
+ */
391
+ observableProto.windowWithCount = function (count, skip) {
392
+ var source = this;
393
+ if (count <= 0) {
394
+ throw new Error(argumentOutOfRange);
395
+ }
396
+ if (arguments.length === 1) {
397
+ skip = count;
398
+ }
399
+ if (skip <= 0) {
400
+ throw new Error(argumentOutOfRange);
401
+ }
402
+ return new AnonymousObservable(function (observer) {
403
+ var m = new SingleAssignmentDisposable(),
404
+ refCountDisposable = new RefCountDisposable(m),
405
+ n = 0,
406
+ q = [],
407
+ createWindow = function () {
408
+ var s = new Subject();
409
+ q.push(s);
410
+ observer.onNext(addRef(s, refCountDisposable));
411
+ };
412
+ createWindow();
413
+ m.setDisposable(source.subscribe(function (x) {
414
+ var s;
415
+ for (var i = 0, len = q.length; i < len; i++) {
416
+ q[i].onNext(x);
417
+ }
418
+ var c = n - count + 1;
419
+ if (c >= 0 && c % skip === 0) {
420
+ s = q.shift();
421
+ s.onCompleted();
422
+ }
423
+ n++;
424
+ if (n % skip === 0) {
425
+ createWindow();
426
+ }
427
+ }, function (exception) {
428
+ while (q.length > 0) {
429
+ q.shift().onError(exception);
430
+ }
431
+ observer.onError(exception);
432
+ }, function () {
433
+ while (q.length > 0) {
434
+ q.shift().onCompleted();
435
+ }
436
+ observer.onCompleted();
437
+ }));
438
+ return refCountDisposable;
439
+ });
440
+ };
441
+
442
+ /**
443
+ * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
444
+ *
445
+ * var res = obs = xs.defaultIfEmpty();
446
+ * 2 - obs = xs.defaultIfEmpty(false);
447
+ *
448
+ * @memberOf Observable#
449
+ * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.
450
+ * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
451
+ */
452
+ observableProto.defaultIfEmpty = function (defaultValue) {
453
+ var source = this;
454
+ if (defaultValue === undefined) {
455
+ defaultValue = null;
456
+ }
457
+ return new AnonymousObservable(function (observer) {
458
+ var found = false;
459
+ return source.subscribe(function (x) {
460
+ found = true;
461
+ observer.onNext(x);
462
+ }, observer.onError.bind(observer), function () {
463
+ if (!found) {
464
+ observer.onNext(defaultValue);
465
+ }
466
+ observer.onCompleted();
467
+ });
468
+ });
469
+ };
470
+
471
+ /**
472
+ * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
473
+ * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.
474
+ *
475
+ * @example
476
+ * var res = obs = xs.distinct();
477
+ * 2 - obs = xs.distinct(function (x) { return x.id; });
478
+ * 2 - obs = xs.distinct(function (x) { return x.id; }, function (x) { return x.toString(); });
479
+ * @param {Function} [keySelector] A function to compute the comparison key for each element.
480
+ * @param {Function} [keySerializer] Used to serialize the given object into a string for object comparison.
481
+ * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.
482
+ */
483
+ observableProto.distinct = function (keySelector, keySerializer) {
484
+ var source = this;
485
+ keySelector || (keySelector = identity);
486
+ keySerializer || (keySerializer = defaultKeySerializer);
487
+ return new AnonymousObservable(function (observer) {
488
+ var hashSet = {};
489
+ return source.subscribe(function (x) {
490
+ var key, serializedKey, otherKey, hasMatch = false;
491
+ try {
492
+ key = keySelector(x);
493
+ serializedKey = keySerializer(key);
494
+ } catch (exception) {
495
+ observer.onError(exception);
496
+ return;
497
+ }
498
+ for (otherKey in hashSet) {
499
+ if (serializedKey === otherKey) {
500
+ hasMatch = true;
501
+ break;
502
+ }
503
+ }
504
+ if (!hasMatch) {
505
+ hashSet[serializedKey] = null;
506
+ observer.onNext(x);
507
+ }
508
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
509
+ });
510
+ };
511
+
512
+ /**
513
+ * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
514
+ *
515
+ * @example
516
+ * var res = observable.groupBy(function (x) { return x.id; });
517
+ * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });
518
+ * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });
519
+ * @param {Function} keySelector A function to extract the key for each element.
520
+ * @param {Function} [elementSelector] A function to map each source element to an element in an observable group.
521
+ * @param {Function} [keySerializer] Used to serialize the given object into a string for object comparison.
522
+ * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
523
+ */
524
+ observableProto.groupBy = function (keySelector, elementSelector, keySerializer) {
525
+ return this.groupByUntil(keySelector, elementSelector, function () {
526
+ return observableNever();
527
+ }, keySerializer);
528
+ };
529
+
530
+ /**
531
+ * Groups the elements of an observable sequence according to a specified key selector function.
532
+ * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
533
+ * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
534
+ *
535
+ * @example
536
+ * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });
537
+ * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });
538
+ * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });
539
+ * @param {Function} keySelector A function to extract the key for each element.
540
+ * @param {Function} durationSelector A function to signal the expiration of a group.
541
+ * @param {Function} [keySerializer] Used to serialize the given object into a string for object comparison.
542
+ * @returns {Observable}
543
+ * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
544
+ * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
545
+ *
546
+ */
547
+ observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector, keySerializer) {
548
+ var source = this;
549
+ elementSelector || (elementSelector = identity);
550
+ keySerializer || (keySerializer = defaultKeySerializer);
551
+ return new AnonymousObservable(function (observer) {
552
+ var map = {},
553
+ groupDisposable = new CompositeDisposable(),
554
+ refCountDisposable = new RefCountDisposable(groupDisposable);
555
+ groupDisposable.add(source.subscribe(function (x) {
556
+ var duration, durationGroup, element, fireNewMapEntry, group, key, serializedKey, md, writer, w;
557
+ try {
558
+ key = keySelector(x);
559
+ serializedKey = keySerializer(key);
560
+ } catch (e) {
561
+ for (w in map) {
562
+ map[w].onError(e);
563
+ }
564
+ observer.onError(e);
565
+ return;
566
+ }
567
+ fireNewMapEntry = false;
568
+ try {
569
+ writer = map[serializedKey];
570
+ if (!writer) {
571
+ writer = new Subject();
572
+ map[serializedKey] = writer;
573
+ fireNewMapEntry = true;
574
+ }
575
+ } catch (e) {
576
+ for (w in map) {
577
+ map[w].onError(e);
578
+ }
579
+ observer.onError(e);
580
+ return;
581
+ }
582
+ if (fireNewMapEntry) {
583
+ group = new GroupedObservable(key, writer, refCountDisposable);
584
+ durationGroup = new GroupedObservable(key, writer);
585
+ try {
586
+ duration = durationSelector(durationGroup);
587
+ } catch (e) {
588
+ for (w in map) {
589
+ map[w].onError(e);
590
+ }
591
+ observer.onError(e);
592
+ return;
593
+ }
594
+ observer.onNext(group);
595
+ md = new SingleAssignmentDisposable();
596
+ groupDisposable.add(md);
597
+ var expire = function () {
598
+ if (serializedKey in map) {
599
+ delete map[serializedKey];
600
+ writer.onCompleted();
601
+ }
602
+ groupDisposable.remove(md);
603
+ };
604
+ md.setDisposable(duration.take(1).subscribe(noop, function (exn) {
605
+ for (w in map) {
606
+ map[w].onError(exn);
607
+ }
608
+ observer.onError(exn);
609
+ }, function () {
610
+ expire();
611
+ }));
612
+ }
613
+ try {
614
+ element = elementSelector(x);
615
+ } catch (e) {
616
+ for (w in map) {
617
+ map[w].onError(e);
618
+ }
619
+ observer.onError(e);
620
+ return;
621
+ }
622
+ writer.onNext(element);
623
+ }, function (ex) {
624
+ for (var w in map) {
625
+ map[w].onError(ex);
626
+ }
627
+ observer.onError(ex);
628
+ }, function () {
629
+ for (var w in map) {
630
+ map[w].onCompleted();
631
+ }
632
+ observer.onCompleted();
633
+ }));
634
+ return refCountDisposable;
635
+ });
636
+ };
637
+
638
+ /** @private */
639
+ var GroupedObservable = (function (_super) {
640
+ inherits(GroupedObservable, _super);
641
+
642
+ function subscribe(observer) {
643
+ return this.underlyingObservable.subscribe(observer);
644
+ }
645
+
646
+ /**
647
+ * @constructor
648
+ * @private
649
+ */
650
+ function GroupedObservable(key, underlyingObservable, mergedDisposable) {
651
+ _super.call(this, subscribe);
652
+ this.key = key;
653
+ this.underlyingObservable = !mergedDisposable ?
654
+ underlyingObservable :
655
+ new AnonymousObservable(function (observer) {
656
+ return new CompositeDisposable(mergedDisposable.getDisposable(), underlyingObservable.subscribe(observer));
657
+ });
658
+ }
659
+
660
+ return GroupedObservable;
661
+ }(Observable));
662
+
663
+ return Rx;
664
+ }));
@@ -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,d){function e(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:C.call(a)}function f(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}var g=c.Observable,h=g.prototype,i=g.never,j=g.throwException,k=c.AnonymousObservable,l=c.Observer,m=c.Subject,n=c.internals,o=c.helpers,p=n.ScheduledObserver,q=c.SingleAssignmentDisposable,r=c.CompositeDisposable,s=c.RefCountDisposable,t=c.Disposable.empty,u=c.Scheduler.immediate,v=o.defaultKeySerializer,w=c.internals.addRef,x=o.identity,y=o.isPromise,z=n.inherits,A=o.noop,B=g.fromPromise,C=Array.prototype.slice,D="Argument out of range";f.prototype.dispose=function(){var a=this;this.scheduler.schedule(function(){a.isDisposed||(a.isDisposed=!0,a.disposable.dispose())})};var E=(function(a){function b(b){a.call(this),this._observer=b,this._state=0}z(b,a);var c=b.prototype;return c.onNext=function(a){this.checkAccess();try{this._observer.onNext(a)}catch(b){throw b}finally{this._state=0}},c.onError=function(a){this.checkAccess();try{this._observer.onError(a)}catch(b){throw b}finally{this._state=2}},c.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(a){throw a}finally{this._state=2}},c.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},b}(l),function(a){function b(){a.apply(this,arguments)}return z(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b}(p));h.observeOn=function(a){var b=this;return new k(function(c){return b.subscribe(new E(a,c))})},h.subscribeOn=function(a){var b=this;return new k(function(c){var d=new q,e=new SerialDisposable;return e.setDisposable(d),d.setDisposable(a.schedule(function(){e.setDisposable(new f(a,b.subscribe(c)))})),e})},g.using=function(a,b){return new k(function(c){var d,e,f=t;try{d=a(),d&&(f=d),e=b(d)}catch(g){return new r(j(g).subscribe(c),f)}return new r(e.subscribe(c),f)})},h.amb=function(a){var b=this;return new k(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new q,j=new q;return y(a)&&(a=B(a)),i.setDisposable(b.subscribe(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()})),j.setDisposable(a.subscribe(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()})),new r(i,j)})},g.amb=function(){function a(a,b){return a.amb(b)}for(var b=i(),c=e(arguments,0),d=0,f=c.length;f>d;d++)b=a(b,c[d]);return b},h.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return F([this,a])};var F=g.onErrorResumeNext=function(){var a=e(arguments,0);return new k(function(b){var c=0,d=new SerialDisposable,e=u.scheduleRecursive(function(e){var f,g;c<a.length?(f=a[c++],y(f)&&(f=B(f)),g=new q,d.setDisposable(g),g.setDisposable(f.subscribe(b.onNext.bind(b),function(){e()},function(){e()}))):b.onCompleted()});return new r(d,e)})};h.bufferWithCount=function(a,b){return"number"!=typeof b&&(b=a),this.windowWithCount(a,b).selectMany(function(a){return a.toArray()}).where(function(a){return a.length>0})},h.windowWithCount=function(a,b){var c=this;if(0>=a)throw new Error(D);if(1===arguments.length&&(b=a),0>=b)throw new Error(D);return new k(function(d){var e=new q,f=new s(e),g=0,h=[],i=function(){var a=new m;h.push(a),d.onNext(w(a,f))};return i(),e.setDisposable(c.subscribe(function(c){for(var d,e=0,f=h.length;f>e;e++)h[e].onNext(c);var j=g-a+1;j>=0&&j%b===0&&(d=h.shift(),d.onCompleted()),g++,g%b===0&&i()},function(a){for(;h.length>0;)h.shift().onError(a);d.onError(a)},function(){for(;h.length>0;)h.shift().onCompleted();d.onCompleted()})),f})},h.defaultIfEmpty=function(a){var b=this;return a===d&&(a=null),new k(function(c){var d=!1;return b.subscribe(function(a){d=!0,c.onNext(a)},c.onError.bind(c),function(){d||c.onNext(a),c.onCompleted()})})},h.distinct=function(a,b){var c=this;return a||(a=x),b||(b=v),new k(function(d){var e={};return c.subscribe(function(c){var f,g,h,i=!1;try{f=a(c),g=b(f)}catch(j){return void d.onError(j)}for(h in e)if(g===h){i=!0;break}i||(e[g]=null,d.onNext(c))},d.onError.bind(d),d.onCompleted.bind(d))})},h.groupBy=function(a,b,c){return this.groupByUntil(a,b,function(){return i()},c)},h.groupByUntil=function(a,b,c,d){var e=this;return b||(b=x),d||(d=v),new k(function(f){var g={},h=new r,i=new s(h);return h.add(e.subscribe(function(e){var j,k,l,n,o,p,r,s,t,u;try{p=a(e),r=d(p)}catch(v){for(u in g)g[u].onError(v);return void f.onError(v)}n=!1;try{t=g[r],t||(t=new m,g[r]=t,n=!0)}catch(v){for(u in g)g[u].onError(v);return void f.onError(v)}if(n){o=new G(p,t,i),k=new G(p,t);try{j=c(k)}catch(v){for(u in g)g[u].onError(v);return void f.onError(v)}f.onNext(o),s=new q,h.add(s);var w=function(){r in g&&(delete g[r],t.onCompleted()),h.remove(s)};s.setDisposable(j.take(1).subscribe(A,function(a){for(u in g)g[u].onError(a);f.onError(a)},function(){w()}))}try{l=b(e)}catch(v){for(u in g)g[u].onError(v);return void f.onError(v)}t.onNext(l)},function(a){for(var b in g)g[b].onError(a);f.onError(a)},function(){for(var a in g)g[a].onCompleted();f.onCompleted()})),i})};var G=function(a){function b(a){return this.underlyingObservable.subscribe(a)}function c(c,d,e){a.call(this,b),this.key=c,this.underlyingObservable=e?new k(function(a){return new r(e.getDisposable(),d.subscribe(a))}):d}return z(c,a),c}(g);return c});