wait()

Creates a waiter function which takes orders and serves orders in a way and calls a ready function when all orders have been served.

This function is valid in v2.0.0 to v2.24.3. This function has been downloaded 63 times.

Parameters

{Function} fnReady
Function to be called when the waiter function is has been called to serve the last remaining order. When called this function will receive all of the orders ever made as the 1st argument and the final order as the 2nd.
{boolean=} opt_clearOrdersAfterReady Optional, Default:false
If true-ish the orders array will be cleared after the fnReady function is called. This prevents previous orders from showing up if fnReady is called multiple times.

Returns

{Function}
A waiter function which take and serve orders. The 1st argument passed to this function should be a boolean indicating that an order is going in. The 2nd argument passed to this function can be any value that represents an order. When this function is called a boolean will be returned indicating whether or not the call was successful. The only way false can be returned by this function is if an order is to be served that doesn't exist.

Required Functions

This function directly requires the following functions which are included automatically:

  • is()
    Tests to see if two or more values are exactly the same. This is similar to === but will also indicate that NaN is NaN and will indicate that -0 is not 0.
  • slice()
    Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.