implement util.once
This commit is contained in:
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…
x
Reference in New Issue
Block a user