Author: ygrego Date: 2015-03-17 09:11:36 +0000 (Tue, 17 Mar 2015) New Revision: 951 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/951 Log: Addition of a new method "timeout" which permit to set a timer and return a Promise in order simulate more easily asynchronous calls. Modified: oipf/js/utils/Utils.js Modified: oipf/js/utils/Utils.js =================================================================== --- oipf/js/utils/Utils.js 2015-03-13 16:42:16 UTC (rev 950) +++ oipf/js/utils/Utils.js 2015-03-17 09:11:36 UTC (rev 951) @@ -2,7 +2,6 @@ * Some code based on RFC 4122, section 4.4 * (Algorithms for Creating a UUID from Truly Random or Pseudo-Random Number). */ - function createUUID() { // http://www.ietf.org/rfc/rfc4122.txt var s = []; @@ -25,3 +24,13 @@ function isMethodImplemented(object, methodName) { return object[methodName]; } + +/* + * Description: + * Encapsulation of function "setTimeout" in order to it be accessible for all object and also reusable. + */ +function timeout(time) { + return new Promise(function(resolve, reject) { + setTimeout(resolve, time); + }); +} \ No newline at end of file
participants (1)
-
ygregoï¼ users.nuiton.org