Pike v8.0 release 1738

Method Concurrent.Future()->then()


Method then

this_program then(void|function(mixed, mixed ... :mixed) onfulfilled, void|function(mixed, mixed ... :mixed) onrejected, mixed ... extra)

Description

JavaScript Promise API close but not identical equivalent of a combined transform() and transform_with().

Parameter onfulfilled

Function to be called on fulfillment. The first argument will be the result of this Future. The return value will be the result of the new Future. If the return value already is a Future, pass it as-is.

Parameter onrejected

Function to be called on failure. The first argument will be the failure result of this Future. The return value will be the failure result of the new Future. If the return value already is a Future, pass it as-is.

Parameter extra

Any extra context needed for onfulfilled and onrejected. They will be provided as arguments two and onwards when the callbacks are called.

Returns

The new Future.

See also

transform(), transform_with(), thencatch(), on_success(), Promise.success(), on_failure(), Promise.failure(), https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise