Ricardo Sanz
Drupal Developer & DevOps
drupal.org/u/tunic
sanzante
jQuery('#grip').click(function() {
jQuery('#panel').slideUp();
});
var doc;
memStorage.get(docId, response => {
doc = memResponse;
if (!memResponse) {
localStorage.get(docId, localResponse => {
doc = localResponse;
if (!localResponse) {
serverStorage.get(docId, serverResponse => {
doc = serverResponse;
if (!serverResponse) {
// Error.
}
});
}
});
});
jQuery('#grip').click(function() {
jQuery('#panel').slideUp();
});
var clockValue = 0;
var clockOn = true;
const btS$ = Rx.Observable.fromEvent(buttonStart, 'click');
const btP$ = Rx.Observable.fromEvent(buttonPause, 'click');
const clock$ = Rx.Observable.interval(1000);
btP$.subscribe(() => clockOn = !clockOn);
clock$.do(x => output1.innerHTML = x)
.combineLatest(btS$, v => v)
.filter(() => clockOn)
.subscribe(() => output2.innerHTML = ++clockValue);
clock$ ---1---2---3---4---5---6---7---8---9------> do ---1---2---3---4---5---6---7---8---9------> btS$ --------x---------------------------------> combineLatest --------2--3---4---5---6---7---8---9------> filter (clockOn) --------2--3---4---6-----------8---9------> btP$ ---------------------x--------x-----------> clockV 000000001112222333344444444444455556666---> clockOn 111111111111111111111000000000011111111--->
var button = document.querySelector('.this');
var clickStream = Rx.Observable.fromEvent(button, 'click');
var text = document.querySelector('h2');
var multiClickStream = clickStream
.buffer(() => Rx.Observable.interval(660))
.map(list => list.length)
.filter(x => x >= 2);
multiClickStream.subscribe(numclicks => {
text.textContent = '' + numclicks + 'x click';
});
multiClickStream.throttle(1000)
.subscribe(suggestion => {
document.querySelector('h2').textContent = ''
});
Rx.Observable.fromEvent(button, 'click')
.map(() => 'https://ejemplo.es/api/clasificacion'
.flatMap(url => http.get(url))
.map(items => items.map(new MyItem(item)))
.subscribe(instancias => this.list = instancias);
Rx.Observable.fromEvent(button, 'click')
.merge(Rx.Observable.interval(60000))
.map(() => 'https://ejemplo.es/api/clasificacion'
.flatMap(url => http.get(url))
.map(items => items.map(new MyItem(item)))
.subscribe(instancias => this.list = instancias);
Rx.Observable.interval(60000)
.filter(() => this.autorefresh)
.merge(Rx.Observable.fromEvent(button, 'click'))
.map(() => 'https://ejemplo.es/api/clasificacion'
.flatMap(url => http.get(url))
.map(items => items.map(new MyItem(item)))
.subscribe(instancias => this.list = instancias);
Rx.Observable.interval(60000)
.filter(() => this.autorefresh)
.merge(Rx.Observable.fromEvent(button, 'click'))
.map(() => 'https://ejemplo.es/api/clasificacion'
.flatMap(url => http.get(url))
.map(items => items.map(new MyItem(item)))
.catch(err => Rx.Observable.of([]))
.subscribe(instancias => this.list = instancias);