Whatever message this page gives is out now! Go check it out!

applyToEitherAsync (Future method)

Last update:
May 18, 2026
When either this Future or another completes successfully first, transforms that value on the async executor.

Description

applyToEitherAsync implements a race between two futures. The winning value is passed to your function; the returned Future carries the transformed result.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.applyToEitherAsync(other, function)

Parameters

ParameterDescription
otherRequired. The other Future to race.
functionRequired. A function that takes the first completed value and returns a transformed value.

See also

Example

Process whichever string result arrives first (from product tests).

<cfscript>
    f1 = runAsync(function() { return "fast"; });
    f2 = runAsync(function() {    sleep(1000);    return "slow";});
    either = f1.applyToEitherAsync(f2, function(x) {    return x & "_processed";});
    writeOutput(either.get()); // fast_processed
</cfscript>
      

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page