rxjs-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/LICENSE +19 -0
  4. data/README.md +14 -0
  5. data/lib/rxjs/rails/engine.rb +7 -0
  6. data/lib/rxjs/rails/railtie.rb +7 -0
  7. data/lib/rxjs/rails/version.rb +7 -0
  8. data/lib/rxjs/rails.rb +8 -0
  9. data/lib/rxjs.rb +1 -0
  10. data/rxjs-rails.gemspec +22 -0
  11. data/vendor/assets/javascripts/rx.aggregates.js +687 -0
  12. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -0
  13. data/vendor/assets/javascripts/rx.async.compat.js +376 -0
  14. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -0
  15. data/vendor/assets/javascripts/rx.async.js +306 -0
  16. data/vendor/assets/javascripts/rx.async.min.js +1 -0
  17. data/vendor/assets/javascripts/rx.binding.js +561 -0
  18. data/vendor/assets/javascripts/rx.binding.min.js +1 -0
  19. data/vendor/assets/javascripts/rx.coincidence.js +691 -0
  20. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -0
  21. data/vendor/assets/javascripts/rx.compat.js +4351 -0
  22. data/vendor/assets/javascripts/rx.compat.min.js +2 -0
  23. data/vendor/assets/javascripts/rx.experimental.js +453 -0
  24. data/vendor/assets/javascripts/rx.experimental.min.js +1 -0
  25. data/vendor/assets/javascripts/rx.joinpatterns.js +418 -0
  26. data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -0
  27. data/vendor/assets/javascripts/rx.lite.compat.js +5188 -0
  28. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -0
  29. data/vendor/assets/javascripts/rx.lite.js +5000 -0
  30. data/vendor/assets/javascripts/rx.lite.min.js +2 -0
  31. data/vendor/assets/javascripts/rx.min.js +2 -0
  32. data/vendor/assets/javascripts/rx.node.js +143 -0
  33. data/vendor/assets/javascripts/rx.testing.js +503 -0
  34. data/vendor/assets/javascripts/rx.testing.min.js +1 -0
  35. data/vendor/assets/javascripts/rx.time.js +1166 -0
  36. data/vendor/assets/javascripts/rx.time.min.js +1 -0
  37. data/vendor/assets/javascripts/rx.virtualtime.js +336 -0
  38. data/vendor/assets/javascripts/rx.virtualtime.min.js +1 -0
  39. metadata +101 -0
@@ -0,0 +1,561 @@
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
+ var Observable = Rx.Observable,
37
+ observableProto = Observable.prototype,
38
+ AnonymousObservable = Rx.Internals.AnonymousObservable,
39
+ Subject = Rx.Subject,
40
+ AsyncSubject = Rx.AsyncSubject,
41
+ Observer = Rx.Observer,
42
+ ScheduledObserver = Rx.Internals.ScheduledObserver,
43
+ disposableCreate = Rx.Disposable.create,
44
+ disposableEmpty = Rx.Disposable.empty,
45
+ CompositeDisposable = Rx.CompositeDisposable,
46
+ currentThreadScheduler = Rx.Scheduler.currentThread,
47
+ inherits = Rx.Internals.inherits,
48
+ addProperties = Rx.Internals.addProperties;
49
+
50
+ // Utilities
51
+ var objectDisposed = 'Object has been disposed';
52
+ function checkDisposed() {
53
+ if (this.isDisposed) {
54
+ throw new Error(objectDisposed);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
60
+ * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
61
+ * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
62
+ *
63
+ * @example
64
+ * 1 - res = source.multicast(observable);
65
+ * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });
66
+ *
67
+ * @param {Function|Subject} subjectOrSubjectSelector
68
+ * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.
69
+ * Or:
70
+ * Subject to push source elements into.
71
+ *
72
+ * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name="subjectOrSubjectSelector" is a factory function.
73
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
74
+ */
75
+ observableProto.multicast = function (subjectOrSubjectSelector, selector) {
76
+ var source = this;
77
+ return typeof subjectOrSubjectSelector === 'function' ?
78
+ new AnonymousObservable(function (observer) {
79
+ var connectable = source.multicast(subjectOrSubjectSelector());
80
+ return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());
81
+ }) :
82
+ new ConnectableObservable(source, subjectOrSubjectSelector);
83
+ };
84
+
85
+ /**
86
+ * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.
87
+ * This operator is a specialization of Multicast using a regular Subject.
88
+ *
89
+ * @example
90
+ * var resres = source.publish();
91
+ * var res = source.publish(function (x) { return x; });
92
+ *
93
+ * @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.
94
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
95
+ */
96
+ observableProto.publish = function (selector) {
97
+ return !selector ?
98
+ this.multicast(new Subject()) :
99
+ this.multicast(function () {
100
+ return new Subject();
101
+ }, selector);
102
+ };
103
+
104
+ /**
105
+ * Returns an observable sequence that shares a single subscription to the underlying sequence.
106
+ * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
107
+ *
108
+ * @example
109
+ * var res = source.share();
110
+ *
111
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
112
+ */
113
+ observableProto.share = function () {
114
+ return this.publish(null).refCount();
115
+ };
116
+
117
+ /**
118
+ * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.
119
+ * This operator is a specialization of Multicast using a AsyncSubject.
120
+ *
121
+ * @example
122
+ * var res = source.publishLast();
123
+ * var res = source.publishLast(function (x) { return x; });
124
+ *
125
+ * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.
126
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
127
+ */
128
+ observableProto.publishLast = function (selector) {
129
+ return !selector ?
130
+ this.multicast(new AsyncSubject()) :
131
+ this.multicast(function () {
132
+ return new AsyncSubject();
133
+ }, selector);
134
+ };
135
+
136
+ /**
137
+ * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.
138
+ * This operator is a specialization of Multicast using a BehaviorSubject.
139
+ *
140
+ * @example
141
+ * var res = source.publishValue(42);
142
+ * var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);
143
+ *
144
+ * @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
145
+ * @param {Mixed} initialValue Initial value received by observers upon subscription.
146
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
147
+ */
148
+ observableProto.publishValue = function (initialValueOrSelector, initialValue) {
149
+ return arguments.length === 2 ?
150
+ this.multicast(function () {
151
+ return new BehaviorSubject(initialValue);
152
+ }, initialValueOrSelector) :
153
+ this.multicast(new BehaviorSubject(initialValueOrSelector));
154
+ };
155
+
156
+ /**
157
+ * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
158
+ * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
159
+ *
160
+ * @example
161
+ * var res = source.shareValue(42);
162
+ *
163
+ * @param {Mixed} initialValue Initial value received by observers upon subscription.
164
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
165
+ */
166
+ observableProto.shareValue = function (initialValue) {
167
+ return this.publishValue(initialValue).
168
+ refCount();
169
+ };
170
+
171
+ /**
172
+ * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
173
+ * This operator is a specialization of Multicast using a ReplaySubject.
174
+ *
175
+ * @example
176
+ * var res = source.replay(null, 3);
177
+ * var res = source.replay(null, 3, 500);
178
+ * var res = source.replay(null, 3, 500, scheduler);
179
+ * var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);
180
+ *
181
+ * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.
182
+ * @param bufferSize [Optional] Maximum element count of the replay buffer.
183
+ * @param window [Optional] Maximum time length of the replay buffer.
184
+ * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
185
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
186
+ */
187
+ observableProto.replay = function (selector, bufferSize, window, scheduler) {
188
+ return !selector ?
189
+ this.multicast(new ReplaySubject(bufferSize, window, scheduler)) :
190
+ this.multicast(function () {
191
+ return new ReplaySubject(bufferSize, window, scheduler);
192
+ }, selector);
193
+ };
194
+
195
+ /**
196
+ * Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
197
+ * This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
198
+ *
199
+ * @example
200
+ * var res = source.replayWhileObserved(3);
201
+ * var res = source.replayWhileObserved(3, 500);
202
+ * var res = source.replayWhileObserved(3, 500, scheduler);
203
+ *
204
+
205
+ * @param bufferSize [Optional] Maximum element count of the replay buffer.
206
+ * @param window [Optional] Maximum time length of the replay buffer.
207
+ * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
208
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
209
+ */
210
+ observableProto.replayWhileObserved = function (bufferSize, window, scheduler) {
211
+ return this.replay(null, bufferSize, window, scheduler).refCount();
212
+ };
213
+
214
+ /** @private */
215
+ var InnerSubscription = function (subject, observer) {
216
+ this.subject = subject;
217
+ this.observer = observer;
218
+ };
219
+
220
+ /**
221
+ * @private
222
+ * @memberOf InnerSubscription
223
+ */
224
+ InnerSubscription.prototype.dispose = function () {
225
+ if (!this.subject.isDisposed && this.observer !== null) {
226
+ var idx = this.subject.observers.indexOf(this.observer);
227
+ this.subject.observers.splice(idx, 1);
228
+ this.observer = null;
229
+ }
230
+ };
231
+
232
+ /**
233
+ * Represents a value that changes over time.
234
+ * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.
235
+ */
236
+ var BehaviorSubject = Rx.BehaviorSubject = (function (_super) {
237
+ function subscribe(observer) {
238
+ checkDisposed.call(this);
239
+ if (!this.isStopped) {
240
+ this.observers.push(observer);
241
+ observer.onNext(this.value);
242
+ return new InnerSubscription(this, observer);
243
+ }
244
+ var ex = this.exception;
245
+ if (ex) {
246
+ observer.onError(ex);
247
+ } else {
248
+ observer.onCompleted();
249
+ }
250
+ return disposableEmpty;
251
+ }
252
+
253
+ inherits(BehaviorSubject, _super);
254
+
255
+ /**
256
+ * @constructor
257
+ * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.
258
+ * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.
259
+ */
260
+ function BehaviorSubject(value) {
261
+ _super.call(this, subscribe);
262
+
263
+ this.value = value,
264
+ this.observers = [],
265
+ this.isDisposed = false,
266
+ this.isStopped = false,
267
+ this.exception = null;
268
+ }
269
+
270
+ addProperties(BehaviorSubject.prototype, Observer, {
271
+ /**
272
+ * Indicates whether the subject has observers subscribed to it.
273
+ * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
274
+ */
275
+ hasObservers: function () {
276
+ return this.observers.length > 0;
277
+ },
278
+ /**
279
+ * Notifies all subscribed observers about the end of the sequence.
280
+ */
281
+ onCompleted: function () {
282
+ checkDisposed.call(this);
283
+ if (!this.isStopped) {
284
+ var os = this.observers.slice(0);
285
+ this.isStopped = true;
286
+ for (var i = 0, len = os.length; i < len; i++) {
287
+ os[i].onCompleted();
288
+ }
289
+
290
+ this.observers = [];
291
+ }
292
+ },
293
+ /**
294
+ * Notifies all subscribed observers about the exception.
295
+ * @param {Mixed} error The exception to send to all observers.
296
+ */
297
+ onError: function (error) {
298
+ checkDisposed.call(this);
299
+ if (!this.isStopped) {
300
+ var os = this.observers.slice(0);
301
+ this.isStopped = true;
302
+ this.exception = error;
303
+
304
+ for (var i = 0, len = os.length; i < len; i++) {
305
+ os[i].onError(error);
306
+ }
307
+
308
+ this.observers = [];
309
+ }
310
+ },
311
+ /**
312
+ * Notifies all subscribed observers about the arrival of the specified element in the sequence.
313
+ * @param {Mixed} value The value to send to all observers.
314
+ */
315
+ onNext: function (value) {
316
+ checkDisposed.call(this);
317
+ if (!this.isStopped) {
318
+ this.value = value;
319
+ var os = this.observers.slice(0);
320
+ for (var i = 0, len = os.length; i < len; i++) {
321
+ os[i].onNext(value);
322
+ }
323
+ }
324
+ },
325
+ /**
326
+ * Unsubscribe all observers and release resources.
327
+ */
328
+ dispose: function () {
329
+ this.isDisposed = true;
330
+ this.observers = null;
331
+ this.value = null;
332
+ this.exception = null;
333
+ }
334
+ });
335
+
336
+ return BehaviorSubject;
337
+ }(Observable));
338
+
339
+ /**
340
+ * Represents an object that is both an observable sequence as well as an observer.
341
+ * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
342
+ */
343
+ var ReplaySubject = Rx.ReplaySubject = (function (_super) {
344
+
345
+ function RemovableDisposable (subject, observer) {
346
+ this.subject = subject;
347
+ this.observer = observer;
348
+ };
349
+
350
+ RemovableDisposable.prototype.dispose = function () {
351
+ this.observer.dispose();
352
+ if (!this.subject.isDisposed) {
353
+ var idx = this.subject.observers.indexOf(this.observer);
354
+ this.subject.observers.splice(idx, 1);
355
+ }
356
+ };
357
+
358
+ function subscribe(observer) {
359
+ var so = new ScheduledObserver(this.scheduler, observer),
360
+ subscription = new RemovableDisposable(this, so);
361
+ checkDisposed.call(this);
362
+ this._trim(this.scheduler.now());
363
+ this.observers.push(so);
364
+
365
+ var n = this.q.length;
366
+
367
+ for (var i = 0, len = this.q.length; i < len; i++) {
368
+ so.onNext(this.q[i].value);
369
+ }
370
+
371
+ if (this.hasError) {
372
+ n++;
373
+ so.onError(this.error);
374
+ } else if (this.isStopped) {
375
+ n++;
376
+ so.onCompleted();
377
+ }
378
+
379
+ so.ensureActive(n);
380
+ return subscription;
381
+ }
382
+
383
+ inherits(ReplaySubject, _super);
384
+
385
+ /**
386
+ * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.
387
+ * @param {Number} [bufferSize] Maximum element count of the replay buffer.
388
+ * @param {Number} [windowSize] Maximum time length of the replay buffer.
389
+ * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.
390
+ */
391
+ function ReplaySubject(bufferSize, windowSize, scheduler) {
392
+ this.bufferSize = bufferSize == null ? Number.MAX_VALUE : bufferSize;
393
+ this.windowSize = windowSize == null ? Number.MAX_VALUE : windowSize;
394
+ this.scheduler = scheduler || currentThreadScheduler;
395
+ this.q = [];
396
+ this.observers = [];
397
+ this.isStopped = false;
398
+ this.isDisposed = false;
399
+ this.hasError = false;
400
+ this.error = null;
401
+ _super.call(this, subscribe);
402
+ }
403
+
404
+ addProperties(ReplaySubject.prototype, Observer, {
405
+ /**
406
+ * Indicates whether the subject has observers subscribed to it.
407
+ * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
408
+ */
409
+ hasObservers: function () {
410
+ return this.observers.length > 0;
411
+ },
412
+ /* @private */
413
+ _trim: function (now) {
414
+ while (this.q.length > this.bufferSize) {
415
+ this.q.shift();
416
+ }
417
+ while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {
418
+ this.q.shift();
419
+ }
420
+ },
421
+ /**
422
+ * Notifies all subscribed observers about the arrival of the specified element in the sequence.
423
+ * @param {Mixed} value The value to send to all observers.
424
+ */
425
+ onNext: function (value) {
426
+ var observer;
427
+ checkDisposed.call(this);
428
+ if (!this.isStopped) {
429
+ var now = this.scheduler.now();
430
+ this.q.push({ interval: now, value: value });
431
+ this._trim(now);
432
+
433
+ var o = this.observers.slice(0);
434
+ for (var i = 0, len = o.length; i < len; i++) {
435
+ observer = o[i];
436
+ observer.onNext(value);
437
+ observer.ensureActive();
438
+ }
439
+ }
440
+ },
441
+ /**
442
+ * Notifies all subscribed observers about the exception.
443
+ * @param {Mixed} error The exception to send to all observers.
444
+ */
445
+ onError: function (error) {
446
+ var observer;
447
+ checkDisposed.call(this);
448
+ if (!this.isStopped) {
449
+ this.isStopped = true;
450
+ this.error = error;
451
+ this.hasError = true;
452
+ var now = this.scheduler.now();
453
+ this._trim(now);
454
+ var o = this.observers.slice(0);
455
+ for (var i = 0, len = o.length; i < len; i++) {
456
+ observer = o[i];
457
+ observer.onError(error);
458
+ observer.ensureActive();
459
+ }
460
+ this.observers = [];
461
+ }
462
+ },
463
+ /**
464
+ * Notifies all subscribed observers about the end of the sequence.
465
+ */
466
+ onCompleted: function () {
467
+ var observer;
468
+ checkDisposed.call(this);
469
+ if (!this.isStopped) {
470
+ this.isStopped = true;
471
+ var now = this.scheduler.now();
472
+ this._trim(now);
473
+ var o = this.observers.slice(0);
474
+ for (var i = 0, len = o.length; i < len; i++) {
475
+ observer = o[i];
476
+ observer.onCompleted();
477
+ observer.ensureActive();
478
+ }
479
+ this.observers = [];
480
+ }
481
+ },
482
+ /**
483
+ * Unsubscribe all observers and release resources.
484
+ */
485
+ dispose: function () {
486
+ this.isDisposed = true;
487
+ this.observers = null;
488
+ }
489
+ });
490
+
491
+ return ReplaySubject;
492
+ }(Observable));
493
+
494
+ /** @private */
495
+ var ConnectableObservable = (function (_super) {
496
+ inherits(ConnectableObservable, _super);
497
+
498
+ /**
499
+ * @constructor
500
+ * @private
501
+ */
502
+ function ConnectableObservable(source, subject) {
503
+ var state = {
504
+ subject: subject,
505
+ source: source.asObservable(),
506
+ hasSubscription: false,
507
+ subscription: null
508
+ };
509
+
510
+ this.connect = function () {
511
+ if (!state.hasSubscription) {
512
+ state.hasSubscription = true;
513
+ state.subscription = new CompositeDisposable(state.source.subscribe(state.subject), disposableCreate(function () {
514
+ state.hasSubscription = false;
515
+ }));
516
+ }
517
+ return state.subscription;
518
+ };
519
+
520
+ function subscribe(observer) {
521
+ return state.subject.subscribe(observer);
522
+ }
523
+
524
+ _super.call(this, subscribe);
525
+ }
526
+
527
+ /**
528
+ * @private
529
+ * @memberOf ConnectableObservable
530
+ */
531
+ ConnectableObservable.prototype.connect = function () { return this.connect(); };
532
+
533
+ /**
534
+ * @private
535
+ * @memberOf ConnectableObservable
536
+ */
537
+ ConnectableObservable.prototype.refCount = function () {
538
+ var connectableSubscription = null, count = 0, source = this;
539
+ return new AnonymousObservable(function (observer) {
540
+ var shouldConnect, subscription;
541
+ count++;
542
+ shouldConnect = count === 1;
543
+ subscription = source.subscribe(observer);
544
+ if (shouldConnect) {
545
+ connectableSubscription = source.connect();
546
+ }
547
+ return disposableCreate(function () {
548
+ subscription.dispose();
549
+ count--;
550
+ if (count === 0) {
551
+ connectableSubscription.dispose();
552
+ }
553
+ });
554
+ });
555
+ };
556
+
557
+ return ConnectableObservable;
558
+ }(Observable));
559
+
560
+ return Rx;
561
+ }));
@@ -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(){if(this.isDisposed)throw new Error(r)}var e=c.Observable,f=e.prototype,g=c.Internals.AnonymousObservable,h=c.Subject,i=c.AsyncSubject,j=c.Observer,k=c.Internals.ScheduledObserver,l=c.Disposable.create,m=c.Disposable.empty,n=c.CompositeDisposable,o=c.Scheduler.currentThread,p=c.Internals.inherits,q=c.Internals.addProperties,r="Object has been disposed";f.multicast=function(a,b){var c=this;return"function"==typeof a?new g(function(d){var e=c.multicast(a());return new n(b(e).subscribe(d),e.connect())}):new v(c,a)},f.publish=function(a){return a?this.multicast(function(){return new h},a):this.multicast(new h)},f.share=function(){return this.publish(null).refCount()},f.publishLast=function(a){return a?this.multicast(function(){return new i},a):this.multicast(new i)},f.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new t(b)},a):this.multicast(new t(a))},f.shareValue=function(a){return this.publishValue(a).refCount()},f.replay=function(a,b,c,d){return a?this.multicast(function(){return new u(b,c,d)},a):this.multicast(new u(b,c,d))},f.replayWhileObserved=function(a,b,c){return this.replay(null,a,b,c).refCount()};var s=function(a,b){this.subject=a,this.observer=b};s.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var t=c.BehaviorSubject=function(a){function b(a){if(d.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new s(this,a);var b=this.exception;return b?a.onError(b):a.onCompleted(),m}function c(c){a.call(this,b),this.value=c,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return p(c,a),q(c.prototype,j,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(d.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(d.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,e=b.length;e>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(d.call(this),!this.isStopped){this.value=a;for(var b=this.observers.slice(0),c=0,e=b.length;e>c;c++)b[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),c}(e),u=c.ReplaySubject=function(a){function b(a,b){this.subject=a,this.observer=b}function c(a){var c=new k(this.scheduler,a),e=new b(this,c);d.call(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var f=this.q.length,g=0,h=this.q.length;h>g;g++)c.onNext(this.q[g].value);return this.hasError?(f++,c.onError(this.error)):this.isStopped&&(f++,c.onCompleted()),c.ensureActive(f),e}function e(b,d,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==d?Number.MAX_VALUE:d,this.scheduler=e||o,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,c)}return b.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1)}},p(e,a),q(e.prototype,j,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){var b;if(d.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var e=this.observers.slice(0),f=0,g=e.length;g>f;f++)b=e[f],b.onNext(a),b.ensureActive()}},onError:function(a){var b;if(d.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var e=this.observers.slice(0),f=0,g=e.length;g>f;f++)b=e[f],b.onError(a),b.ensureActive();this.observers=[]}},onCompleted:function(){var a;if(d.call(this),!this.isStopped){this.isStopped=!0;var b=this.scheduler.now();this._trim(b);for(var c=this.observers.slice(0),e=0,f=c.length;f>e;e++)a=c[e],a.onCompleted(),a.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),e}(e),v=function(a){function b(b,c){function d(a){return e.subject.subscribe(a)}var e={subject:c,source:b.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return e.hasSubscription||(e.hasSubscription=!0,e.subscription=new n(e.source.subscribe(e.subject),l(function(){e.hasSubscription=!1}))),e.subscription},a.call(this,d)}return p(b,a),b.prototype.connect=function(){return this.connect()},b.prototype.refCount=function(){var a=null,b=0,c=this;return new g(function(d){var e,f;return b++,e=1===b,f=c.subscribe(d),e&&(a=c.connect()),l(function(){f.dispose(),b--,0===b&&a.dispose()})})},b}(e);return c});