_.after(n次后出发某个函数)
语法:
_.after(n, func)
源代码链接:source
npm包链接:npm package
描述:
_.before
的反向函数;此方法创建一个函数,当他被调用n
或更多次之后将马上触发func
。
开始版本:0.1.0
参数:
n (number)
: func 方法应该在调用多少次后才执行。func (Function)
: 用来限定的函数。
返回值:
(Function)
: 返回新的限定函数。
例子:
var saves = ['profile', 'settings'];
var done = _.after(saves.length, function() {
console.log('done saving!');
});
_.forEach(saves, function(type) {
asyncSave({ 'type': type, 'complete': done });
});
// => Logs 'done saving!' after the two async saves have completed.
Last updated
Was this helpful?