Method Concurrent.AggregatedPromise()->fold()


Method fold

this_program fold(mixed initial, function(mixed, mixed, __unknown__ ... :mixed) fun, mixed ... extra)

Parameter initial

Initial value of the accumulator.

Parameter fun

Function to apply. The first argument is the result of one of the futures. The second argument is the current value of the accumulator.

Parameter extra

Any extra context needed for fun. They will be provided as arguments three and onwards when fun is called.

Returns

The new Promise.

Note

If fun throws an error it will fail the Future.

Note

fun may be called in any order, and will be called once for every Future it depends upon, unless one of the calls fails in which case no further calls will be performed.

See also

depend(), Concurrent.fold()