Skip to content

Instantly share code, notes, and snippets.

View tiagogm's full-sized avatar

Tiago Morais tiagogm

View GitHub Profile
@tiagogm
tiagogm / Timer.js
Created April 8, 2017 19:17 — forked from theprojectsomething/Timer.js
Timer - a simple JS timing implementation utilising requestAnimationFrame.
/*
Timer
- utilises animation frames (with a fallback to setTimeout when using the polyfill, below)
- returns remaining (or running) time
- pass a callback [fn], with an optional duration [ms] and autotart [bool], to the constructor or 'init' method
eg. new Timer(foo, 1000) *or* (new Timer()).init(foo, 0, true)
- for uniform x-browser support combine with the requestAnimationFrame polyfill from Erik Möller, et. al.
[https://github.com/darius/requestAnimationFrame]
*/
import {logger} from 'shared/components/utilities/logger';
export function withSpinner(target, key, descriptor) {
let ptr = descriptor.value;
descriptor.value = function(...args) {
if (this.spinner) {
this.spinner.setLoading(true);
}
return ptr.apply(this, args)
.then(() => {