与_.before的相反; 这个方法创建一个调用func的函数,一旦它被调用n次或更多次。
0.1.0
n
(number):调用前func
的调用次数。 func
(功能):限制功能。 (功能):返回新的限制功能。
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.Try in REPL