rxjs-rails 2.3.9 → 2.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +174 -204
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +1626 -1528
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
  7. data/vendor/assets/javascripts/rx.all.js +1624 -1526
  8. data/vendor/assets/javascripts/rx.all.min.js +3 -3
  9. data/vendor/assets/javascripts/rx.async.compat.js +241 -0
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +241 -0
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +3 -3
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.binding.js +350 -378
  16. data/vendor/assets/javascripts/rx.binding.min.js +1 -1
  17. data/vendor/assets/javascripts/rx.coincidence.js +16 -21
  18. data/vendor/assets/javascripts/rx.compat.js +633 -683
  19. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  20. data/vendor/assets/javascripts/rx.js +633 -683
  21. data/vendor/assets/javascripts/rx.lite.compat.js +941 -1137
  22. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  23. data/vendor/assets/javascripts/rx.lite.extras.js +58 -74
  24. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
  25. data/vendor/assets/javascripts/rx.lite.js +941 -1137
  26. data/vendor/assets/javascripts/rx.lite.min.js +2 -2
  27. data/vendor/assets/javascripts/rx.min.js +2 -2
  28. data/vendor/assets/javascripts/rx.time.js +182 -212
  29. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  30. metadata +10 -10
@@ -33,27 +33,26 @@
33
33
  }
34
34
  }.call(this, function (root, exp, Rx, undefined) {
35
35
 
36
- var Observable = Rx.Observable,
37
- observableProto = Observable.prototype,
38
- AnonymousObservable = Rx.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
- }
36
+ var Observable = Rx.Observable,
37
+ observableProto = Observable.prototype,
38
+ AnonymousObservable = Rx.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
+ isFunction = Rx.helpers.isFunction,
48
+ inherits = Rx.internals.inherits,
49
+ addProperties = Rx.internals.addProperties;
50
+
51
+ // Utilities
52
+ var objectDisposed = 'Object has been disposed';
53
+ function checkDisposed() {
54
+ if (this.isDisposed) { throw new Error(objectDisposed); }
55
+ }
57
56
 
58
57
  /**
59
58
  * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
@@ -76,121 +75,114 @@
76
75
  var source = this;
77
76
  return typeof subjectOrSubjectSelector === 'function' ?
78
77
  new AnonymousObservable(function (observer) {
79
- var connectable = source.multicast(subjectOrSubjectSelector());
80
- return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());
78
+ var connectable = source.multicast(subjectOrSubjectSelector());
79
+ return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());
81
80
  }) :
82
81
  new ConnectableObservable(source, subjectOrSubjectSelector);
83
82
  };
84
83
 
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
- };
84
+ /**
85
+ * 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.
86
+ * This operator is a specialization of Multicast using a regular Subject.
87
+ *
88
+ * @example
89
+ * var resres = source.publish();
90
+ * var res = source.publish(function (x) { return x; });
91
+ *
92
+ * @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.
93
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
94
+ */
95
+ observableProto.publish = function (selector) {
96
+ return selector && isFunction(selector) ?
97
+ this.multicast(function () { return new Subject(); }, selector) :
98
+ this.multicast(new Subject());
99
+ };
103
100
 
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
- };
101
+ /**
102
+ * Returns an observable sequence that shares a single subscription to the underlying sequence.
103
+ * 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.
104
+ *
105
+ * @example
106
+ * var res = source.share();
107
+ *
108
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
109
+ */
110
+ observableProto.share = function () {
111
+ return this.publish().refCount();
112
+ };
116
113
 
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
- };
114
+ /**
115
+ * 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.
116
+ * This operator is a specialization of Multicast using a AsyncSubject.
117
+ *
118
+ * @example
119
+ * var res = source.publishLast();
120
+ * var res = source.publishLast(function (x) { return x; });
121
+ *
122
+ * @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.
123
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
124
+ */
125
+ observableProto.publishLast = function (selector) {
126
+ return selector && isFunction(selector) ?
127
+ this.multicast(function () { return new AsyncSubject(); }, selector) :
128
+ this.multicast(new AsyncSubject());
129
+ };
135
130
 
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
- };
131
+ /**
132
+ * 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.
133
+ * This operator is a specialization of Multicast using a BehaviorSubject.
134
+ *
135
+ * @example
136
+ * var res = source.publishValue(42);
137
+ * var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);
138
+ *
139
+ * @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.
140
+ * @param {Mixed} initialValue Initial value received by observers upon subscription.
141
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
142
+ */
143
+ observableProto.publishValue = function (initialValueOrSelector, initialValue) {
144
+ return arguments.length === 2 ?
145
+ this.multicast(function () {
146
+ return new BehaviorSubject(initialValue);
147
+ }, initialValueOrSelector) :
148
+ this.multicast(new BehaviorSubject(initialValueOrSelector));
149
+ };
155
150
 
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
- };
151
+ /**
152
+ * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
153
+ * 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.
154
+ *
155
+ * @example
156
+ * var res = source.shareValue(42);
157
+ *
158
+ * @param {Mixed} initialValue Initial value received by observers upon subscription.
159
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
160
+ */
161
+ observableProto.shareValue = function (initialValue) {
162
+ return this.publishValue(initialValue).refCount();
163
+ };
170
164
 
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
- };
165
+ /**
166
+ * 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.
167
+ * This operator is a specialization of Multicast using a ReplaySubject.
168
+ *
169
+ * @example
170
+ * var res = source.replay(null, 3);
171
+ * var res = source.replay(null, 3, 500);
172
+ * var res = source.replay(null, 3, 500, scheduler);
173
+ * var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);
174
+ *
175
+ * @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.
176
+ * @param bufferSize [Optional] Maximum element count of the replay buffer.
177
+ * @param window [Optional] Maximum time length of the replay buffer.
178
+ * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
179
+ * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
180
+ */
181
+ observableProto.replay = function (selector, bufferSize, window, scheduler) {
182
+ return selector && isFunction(selector) ?
183
+ this.multicast(function () { return new ReplaySubject(bufferSize, window, scheduler); }, selector) :
184
+ this.multicast(new ReplaySubject(bufferSize, window, scheduler));
185
+ };
194
186
 
195
187
  /**
196
188
  * 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.
@@ -229,267 +221,247 @@
229
221
  }
230
222
  };
231
223
 
224
+ /**
225
+ * Represents a value that changes over time.
226
+ * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.
227
+ */
228
+ var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) {
229
+ function subscribe(observer) {
230
+ checkDisposed.call(this);
231
+ if (!this.isStopped) {
232
+ this.observers.push(observer);
233
+ observer.onNext(this.value);
234
+ return new InnerSubscription(this, observer);
235
+ }
236
+ var ex = this.exception;
237
+ if (ex) {
238
+ observer.onError(ex);
239
+ } else {
240
+ observer.onCompleted();
241
+ }
242
+ return disposableEmpty;
243
+ }
244
+
245
+ inherits(BehaviorSubject, __super__);
246
+
232
247
  /**
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;
248
+ * @constructor
249
+ * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.
250
+ * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.
251
+ */
252
+ function BehaviorSubject(value) {
253
+ __super__.call(this, subscribe);
254
+ this.value = value,
255
+ this.observers = [],
256
+ this.isDisposed = false,
257
+ this.isStopped = false,
258
+ this.exception = null;
259
+ }
260
+
261
+ addProperties(BehaviorSubject.prototype, Observer, {
262
+ /**
263
+ * Indicates whether the subject has observers subscribed to it.
264
+ * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
265
+ */
266
+ hasObservers: function () {
267
+ return this.observers.length > 0;
268
+ },
269
+ /**
270
+ * Notifies all subscribed observers about the end of the sequence.
271
+ */
272
+ onCompleted: function () {
273
+ checkDisposed.call(this);
274
+ if (this.isStopped) { return; }
275
+ this.isStopped = true;
276
+ for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
277
+ os[i].onCompleted();
251
278
  }
252
279
 
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;
280
+ this.observers = [];
281
+ },
282
+ /**
283
+ * Notifies all subscribed observers about the exception.
284
+ * @param {Mixed} error The exception to send to all observers.
285
+ */
286
+ onError: function (error) {
287
+ checkDisposed.call(this);
288
+ if (this.isStopped) { return; }
289
+ this.isStopped = true;
290
+ this.exception = error;
291
+
292
+ for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
293
+ os[i].onError(error);
268
294
  }
269
295
 
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
- });
296
+ this.observers = [];
297
+ },
298
+ /**
299
+ * Notifies all subscribed observers about the arrival of the specified element in the sequence.
300
+ * @param {Mixed} value The value to send to all observers.
301
+ */
302
+ onNext: function (value) {
303
+ checkDisposed.call(this);
304
+ if (this.isStopped) { return; }
305
+ this.value = value;
306
+ for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
307
+ os[i].onNext(value);
308
+ }
309
+ },
310
+ /**
311
+ * Unsubscribe all observers and release resources.
312
+ */
313
+ dispose: function () {
314
+ this.isDisposed = true;
315
+ this.observers = null;
316
+ this.value = null;
317
+ this.exception = null;
318
+ }
319
+ });
320
+
321
+ return BehaviorSubject;
322
+ }(Observable));
335
323
 
336
- return BehaviorSubject;
337
- }(Observable));
324
+ /**
325
+ * Represents an object that is both an observable sequence as well as an observer.
326
+ * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
327
+ */
328
+ var ReplaySubject = Rx.ReplaySubject = (function (__super__) {
329
+
330
+ function createRemovableDisposable(subject, observer) {
331
+ return disposableCreate(function () {
332
+ observer.dispose();
333
+ !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1);
334
+ });
335
+ }
338
336
 
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
- }
337
+ function subscribe(observer) {
338
+ var so = new ScheduledObserver(this.scheduler, observer),
339
+ subscription = createRemovableDisposable(this, so);
340
+ checkDisposed.call(this);
341
+ this._trim(this.scheduler.now());
342
+ this.observers.push(so);
343
+
344
+ var n = this.q.length;
345
+
346
+ for (var i = 0, len = this.q.length; i < len; i++) {
347
+ so.onNext(this.q[i].value);
348
+ }
349
+
350
+ if (this.hasError) {
351
+ n++;
352
+ so.onError(this.error);
353
+ } else if (this.isStopped) {
354
+ n++;
355
+ so.onCompleted();
356
+ }
357
+
358
+ so.ensureActive(n);
359
+ return subscription;
360
+ }
382
361
 
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
- }
362
+ inherits(ReplaySubject, __super__);
403
363
 
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
- });
364
+ /**
365
+ * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.
366
+ * @param {Number} [bufferSize] Maximum element count of the replay buffer.
367
+ * @param {Number} [windowSize] Maximum time length of the replay buffer.
368
+ * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.
369
+ */
370
+ function ReplaySubject(bufferSize, windowSize, scheduler) {
371
+ this.bufferSize = bufferSize == null ? Number.MAX_VALUE : bufferSize;
372
+ this.windowSize = windowSize == null ? Number.MAX_VALUE : windowSize;
373
+ this.scheduler = scheduler || currentThreadScheduler;
374
+ this.q = [];
375
+ this.observers = [];
376
+ this.isStopped = false;
377
+ this.isDisposed = false;
378
+ this.hasError = false;
379
+ this.error = null;
380
+ __super__.call(this, subscribe);
381
+ }
490
382
 
491
- return ReplaySubject;
492
- }(Observable));
383
+ addProperties(ReplaySubject.prototype, Observer, {
384
+ /**
385
+ * Indicates whether the subject has observers subscribed to it.
386
+ * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
387
+ */
388
+ hasObservers: function () {
389
+ return this.observers.length > 0;
390
+ },
391
+ _trim: function (now) {
392
+ while (this.q.length > this.bufferSize) {
393
+ this.q.shift();
394
+ }
395
+ while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {
396
+ this.q.shift();
397
+ }
398
+ },
399
+ /**
400
+ * Notifies all subscribed observers about the arrival of the specified element in the sequence.
401
+ * @param {Mixed} value The value to send to all observers.
402
+ */
403
+ onNext: function (value) {
404
+ checkDisposed.call(this);
405
+ if (this.isStopped) { return; }
406
+ var now = this.scheduler.now();
407
+ this.q.push({ interval: now, value: value });
408
+ this._trim(now);
409
+
410
+ var o = this.observers.slice(0);
411
+ for (var i = 0, len = o.length; i < len; i++) {
412
+ var observer = o[i];
413
+ observer.onNext(value);
414
+ observer.ensureActive();
415
+ }
416
+ },
417
+ /**
418
+ * Notifies all subscribed observers about the exception.
419
+ * @param {Mixed} error The exception to send to all observers.
420
+ */
421
+ onError: function (error) {
422
+ checkDisposed.call(this);
423
+ if (this.isStopped) { return; }
424
+ this.isStopped = true;
425
+ this.error = error;
426
+ this.hasError = true;
427
+ var now = this.scheduler.now();
428
+ this._trim(now);
429
+ var o = this.observers.slice(0);
430
+ for (var i = 0, len = o.length; i < len; i++) {
431
+ var observer = o[i];
432
+ observer.onError(error);
433
+ observer.ensureActive();
434
+ }
435
+ this.observers = [];
436
+ },
437
+ /**
438
+ * Notifies all subscribed observers about the end of the sequence.
439
+ */
440
+ onCompleted: function () {
441
+ checkDisposed.call(this);
442
+ if (this.isStopped) { return; }
443
+ this.isStopped = true;
444
+ var now = this.scheduler.now();
445
+ this._trim(now);
446
+ var o = this.observers.slice(0);
447
+ for (var i = 0, len = o.length; i < len; i++) {
448
+ var observer = o[i];
449
+ observer.onCompleted();
450
+ observer.ensureActive();
451
+ }
452
+ this.observers = [];
453
+ },
454
+ /**
455
+ * Unsubscribe all observers and release resources.
456
+ */
457
+ dispose: function () {
458
+ this.isDisposed = true;
459
+ this.observers = null;
460
+ }
461
+ });
462
+
463
+ return ReplaySubject;
464
+ }(Observable));
493
465
 
494
466
  var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {
495
467
  inherits(ConnectableObservable, __super__);