The load event is fired when a resource and its dependent resources have finished loading.
window.addEventListener("load", function(event) {
console.log("All resources finished loading!");
});
var Upload = function (file) { | |
this.file = file; | |
}; | |
Upload.prototype.getType = function() { | |
return this.file.type; | |
}; | |
Upload.prototype.getSize = function() { | |
return this.file.size; | |
}; |
// fade out | |
function fade(el) { | |
var op = 1; | |
var timer = setInterval(function () { | |
if (op <= 0.1){ | |
clearInterval(timer); | |
el.style.display = 'none'; | |
} | |
el.style.opacity = op; |
<body> | |
<p> | |
<a><span>Hello</span></a> | |
</p> | |
<script> | |
const spanEl = document.querySelector('span'); | |
spanEl.addEventListener('click', handler, false); | |
const aEl = document.querySelector('a'); |
import { range } from 'rxjs/observable/range'; | |
import { map, filter, scan } from 'rxjs/operators'; | |
const source$ = range(0, 10); | |
source$.pipe( | |
filter(x => x % 2 === 0), | |
map(x => x + x), | |
scan((acc, x) => acc + x, 0) | |
) |
import { interval } from 'rxjs/observable/interval'; | |
import { map, take, toArray } from 'rxjs/operators'; | |
/** | |
* an operator that takes every Nth value | |
*/ | |
const takeEveryNth = (n: number) => <T>(source: Observable<T>) => | |
new Observable(observer => { | |
let count = 0; | |
return source.subscribe({ |
// Using the bundle | |
import * as Rx from "rxjs"; | |
const name = Rx.Observable.ajax | |
.getJSON<{ name: string }>("/api/employees/alice") | |
.map(employee => employee.name) | |
.catch(error => Rx.Observable.of(null)); | |
// Using prototype patching | |
import { Observable } from "rxjs/Observable"; |
{
// Force to use pipeable in RxJS
"rxjs-no-add": { "severity": "error" },
"rxjs-no-operator": { "severity": "error" },
"rxjs-no-patched": { "severity": "error" },
"rxjs-no-wholesale": { "severity": "error" }
// Force to use pipeable in RxJS
}