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.
- checksums.yaml +4 -4
- data/lib/rxjs/rails/version.rb +1 -1
- data/vendor/assets/javascripts/rx.aggregates.js +174 -204
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.all.compat.js +1626 -1528
- data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
- data/vendor/assets/javascripts/rx.all.js +1624 -1526
- data/vendor/assets/javascripts/rx.all.min.js +3 -3
- data/vendor/assets/javascripts/rx.async.compat.js +241 -0
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +241 -0
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.backpressure.js +3 -3
- data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
- data/vendor/assets/javascripts/rx.binding.js +350 -378
- data/vendor/assets/javascripts/rx.binding.min.js +1 -1
- data/vendor/assets/javascripts/rx.coincidence.js +16 -21
- data/vendor/assets/javascripts/rx.compat.js +633 -683
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.js +633 -683
- data/vendor/assets/javascripts/rx.lite.compat.js +941 -1137
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.extras.js +58 -74
- data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
- data/vendor/assets/javascripts/rx.lite.js +941 -1137
- data/vendor/assets/javascripts/rx.lite.min.js +2 -2
- data/vendor/assets/javascripts/rx.min.js +2 -2
- data/vendor/assets/javascripts/rx.time.js +182 -212
- data/vendor/assets/javascripts/rx.time.min.js +1 -1
- metadata +10 -10
@@ -33,27 +33,26 @@
|
|
33
33
|
}
|
34
34
|
}.call(this, function (root, exp, Rx, undefined) {
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
80
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
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
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
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
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
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
|
-
*
|
234
|
-
*
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
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
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
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
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
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
|
-
|
337
|
-
|
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
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
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
|
-
|
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
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
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
|
-
|
492
|
-
|
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__);
|