RxJS tests
by brian428
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.2.0/Rx.js"></script>
<ul>
<li><a href="https://gist.github.com/btroncone/d6cf141d6f2c00dc6b35" target="_blank">Operator Examples</a></li>
<li><a href="https://github.com/Reactive-Extensions/RxJS/tree/master/doc#reactive-extensions-class-library" target="_blank">RxJS API Docs</a></li>
</ul>
<div id="autocomplete"></div>
TypeScript
var array = [
900,
200,
900,
900
];
var source1 = Rx.Observable.of(
array,
function (x) { return Rx.Observable.timer(x) }
)
.map(function(x, i) { return i; })
.debounceTime(700);
var subscription = source1.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});
var times = [
{ value: 0, time: 100 },
{ value: 1, time: 600 },
{ value: 2, time: 400 },
{ value: 3, time: 400 },
{ value: 4, time: 700 },
{ value: 5, time: 400 },
{ value: 6, time: 400 }
];
// Delay each item by time and project value;
var source2 = Rx.Observable.from(times)
.mergeMap(function (item) {
return Rx.Observable
.of(item.value)
.delay(item.time);
})
.debounceTime(500 /* ms */);
var subscription = source2.subscribe(
function (x) {
console.log('2Next: %s', x);
},
function (err) {
console.log('2Error: %s', err);
},
function () {
console.log('2Completed');
});