Skip to main content

after

_.after(func, n) # Ⓢ [Ⓣ][1] Ⓝ

The opposite of _.before; this method creates a function that invokes



func once it's called n or more times.

Since​

0.1.0

Arguments​

  1. func (Function): The function to restrict.
  2. n (number): The number of calls before func is invoked.

Returns​

(Function): Returns the new restricted function.

Example​

var saves = ['profile', 'settings'];

var done = _.after(function() {
console.log('done saving!');
}, saves.length);

_.forEach(function(type) {
asyncSave({ 'type': type, 'complete': done });
}, saves);
// => Logs 'done saving!' after the two async saves have completed.