diff --git a/www/common/common-util.js b/www/common/common-util.js index 8cbde420c..e42a0249c 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -170,5 +170,15 @@ define([], function () { return parts[0]; }; + /* for wrapping async functions such that they can only be called once */ + Util.once = function (f) { + var called; + return function () { + if (called) { return; } + called = true; + f.apply(this, Array.prototype.slice.call(arguments)); + }; + }; + return Util; });