implement util.once

pull/1/head
ansuz 7 years ago
parent 47ec959032
commit 1b97996ef8

@ -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;
});

Loading…
Cancel
Save