mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Documenting _.once
This commit is contained in:
17
index.html
17
index.html
@@ -160,7 +160,7 @@
|
|||||||
<span class="methods"><a href="#bind">bind</a>, <a href="#bindAll">bindAll</a>,
|
<span class="methods"><a href="#bind">bind</a>, <a href="#bindAll">bindAll</a>,
|
||||||
<a href="#memoize">memoize</a>, <a href="#delay">delay</a>, <a href="#defer">defer</a>,
|
<a href="#memoize">memoize</a>, <a href="#delay">delay</a>, <a href="#defer">defer</a>,
|
||||||
<a href="#throttle">throttle</a>, <a href="#debounce">debounce</a>,
|
<a href="#throttle">throttle</a>, <a href="#debounce">debounce</a>,
|
||||||
<a href="#wrap">wrap</a>, <a href="#compose">compose</a></span>
|
<a href="#once">once</a>, <a href="#wrap">wrap</a>, <a href="#compose">compose</a></span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -738,6 +738,21 @@ $(window).scroll(throttled);
|
|||||||
<pre>
|
<pre>
|
||||||
var lazyLayout = _.debounce(calculateLayout, 300);
|
var lazyLayout = _.debounce(calculateLayout, 300);
|
||||||
$(window).resize(lazyLayout);
|
$(window).resize(lazyLayout);
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p id="once">
|
||||||
|
<b class="header">once</b><code>_.once(function)</code>
|
||||||
|
<br />
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
var initialize = _.once(createApplication);
|
||||||
|
initialize();
|
||||||
|
initialize();
|
||||||
|
// Application is only created once.
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p id="wrap">
|
<p id="wrap">
|
||||||
|
|||||||
Reference in New Issue
Block a user