From 065dcbb27ba35e56f6d32529aacd4772468f178c Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sun, 20 Mar 2011 20:02:52 -0400 Subject: [PATCH] Documenting _.once --- index.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 83386bb5e..1d87bdd13 100644 --- a/index.html +++ b/index.html @@ -160,7 +160,7 @@ bind, bindAll, memoize, delay, defer, throttle, debounce, - wrap, compose + once, wrap, compose

@@ -738,6 +738,21 @@ $(window).scroll(throttled);

 var lazyLayout = _.debounce(calculateLayout, 300);
 $(window).resize(lazyLayout);
+
+ +

+ once_.once(function) +
+ Creates a version of the function that can only be called one time. + Repeated calls to the modified function will have no effect, returning + the value from the original call. Useful for initialization functions, + instead of having to set a boolean flag and then check it later. +

+
+var initialize = _.once(createApplication);
+initialize();
+initialize();
+// Application is only created once.