mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 19:37:49 +00:00
Rework the doc example for _.after.
This commit is contained in:
17
lodash.js
17
lodash.js
@@ -5103,8 +5103,8 @@
|
|||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function this is restricted to executing `func` with the `this`
|
* Creates a function that executes `func`, with the `this` binding and
|
||||||
* binding and arguments of the created function, only after it is called `n` times.
|
* arguments of the created function, only after being called `n` times.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -5115,11 +5115,16 @@
|
|||||||
* @returns {Function} Returns the new restricted function.
|
* @returns {Function} Returns the new restricted function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var renderNotes = _.after(notes.length, render);
|
* var saves = ['profile', 'settings'];
|
||||||
* _.forEach(notes, function(note) {
|
*
|
||||||
* note.asyncSave({ 'success': renderNotes });
|
* var done = _.after(saves.length, function() {
|
||||||
|
* console.log('Done saving!');
|
||||||
* });
|
* });
|
||||||
* // `renderNotes` is run once, after all notes have saved
|
*
|
||||||
|
* _.forEach(saves, function(type) {
|
||||||
|
* asyncSave({ 'type': type, 'complete': done });
|
||||||
|
* });
|
||||||
|
* // => logs 'Done saving!', after all saves have completed
|
||||||
*/
|
*/
|
||||||
function after(n, func) {
|
function after(n, func) {
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user