Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.
[subscriptionDelay]
(Observable
): Sequence indicating the delay for the subscription to the source.delayDurationSelector
(Function
): Selector function to retrieve a sequence indicating the delay for each given element.
(Observable
): Time-shifted sequence.
/* With subscriptionDelay */
var source = Rx.Observable
.range(0, 3)
.delayWithSelector(
Rx.Observable.timer(300),
function (x) {
return Rx.Observable.timer(x * 400);
}
)
.timeInterval()
.map(function (x) { return x.value + ':' + x.interval; });
var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
// => Next: 0:300
// => Next: 1:400
// => Next: 2:400
// => Completed
/* Without subscriptionDelay */
var source = Rx.Observable
.range(0, 3)
.delayWithSelector(
function (x) {
return Rx.Observable.timer(x * 400);
})
.timeInterval()
.map(function (x) { return x.value + ':' + x.interval; });
var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
// => Next: 0:0
// => Next: 1:400
// => Next: 2:400
// => Completed
File:
Dist:
Prerequisites:
rx
.time.jsrx.lite.js
| rx.lite.compat.js
NPM Packages:
NuGet Packages:
Unit Tests: