Skip to content

Instantly share code, notes, and snippets.

@dimorphic
Created February 10, 2017 11:11
Show Gist options
  • Select an option

  • Save dimorphic/5e34f9f201b09421ea20945b75974ab2 to your computer and use it in GitHub Desktop.

Select an option

Save dimorphic/5e34f9f201b09421ea20945b75974ab2 to your computer and use it in GitHub Desktop.
timeout decorator
// ref: http://blog.wolksoftware.com/decorators-reflection-javascript-typescript
// ref: https://medium.com/@NetanelBasal/javascript-make-your-code-cleaner-with-decorators-d34fc72af947#.fe9f2rfb8
export function timeout( milliseconds: number = 0 ) {
return function( target, key, descriptor ) {
var originalMethod = descriptor.value;
descriptor.value = function (...args) {
setTimeout(() => {
originalMethod.apply(this, args);
}, milliseconds);
};
return descriptor;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment