This is RxJS v 4. Find the latest version here
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.
This operator is a specialization of multicast
using a Rx.ReplaySubject
.
[selector]
(Function
): 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.[bufferSize]
(Number
): Maximum element count of the replay buffer.[window]
(Number
): Maximum time length of the replay buffer in milliseconds.[scheduler]
(Scheduler
): Scheduler where connected observers within the selector function will be invoked on.
(Observable
): An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
var interval = Rx.Observable.interval(1000);
var source = interval
.take(2)
.do(function (x) {
console.log('Side effect');
});
var published = source
.replay(function (x) {
return x.take(2).repeat(2);
}, 3);
published.subscribe(createObserver('SourceA'));
published.subscribe(createObserver('SourceB'));
function createObserver(tag) {
return Rx.Observer.create(
function (x) {
console.log('Next: ' + tag + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
}
// => Side effect
// => Next: SourceA0
// => Side effect
// => Next: SourceB0
// => Side effect
// => Next: SourceA1
// => Next: SourceA0
// => Next: SourceA1
// => Completed
// => Side effect
// => Next: SourceB1
// => Next: SourceB0
// => Next: SourceB1
// => Completed
File:
Dist:
Prerequisites:
- If using
rx.binding.js
NPM Packages:
NuGet Packages:
Unit Tests: