Skip to content

Commit 9b346ed

Browse files
committed
docs for once
1 parent a675700 commit 9b346ed

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cms/static/cms/js/modules/cms.base.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,19 @@ var CMS = {
522522
return root.trigger(_ns(eventName), [payload]);
523523
},
524524

525+
/**
526+
* Returns a function that wraps the passed function so the wrapped function
527+
* is executed only once, no matter how many times the wrapper function is executed.
528+
*
529+
* @method once
530+
* @param {Function} fn function to be executed only once
531+
* @return {Function}
532+
*/
525533
once: function once(fn) {
526534
var result;
527535
var didRunOnce = false;
528536

529537
return function () {
530-
console.log('running "once", did already run?', didRunOnce);
531538
if (!didRunOnce) {
532539
didRunOnce = true;
533540
result = fn.apply(this, arguments);

0 commit comments

Comments
 (0)