2019-03-14 10:14:42 -04:00

12 lines
510 B
JavaScript

/*
* This delay allows the thread to finish assigning its on* methods
* before invoking the delay callback. This is purely a timing hack.
* http://geekabyte.blogspot.com/2014/01/javascript-effect-of-setting-settimeout.html
*
* @param {callback: function} the callback which will be invoked after the timeout
* @parma {context: object} the context in which to invoke the function
*/
export default function delay(callback, context) {
setTimeout(timeoutContext => callback.call(timeoutContext), 4, context);
}