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

thenComposeAsync (Future method)

Last update:
May 18, 2026
Flattens a Future-of-Future: when this Future succeeds, your function returns another Future, and the chain follows that inner Future.

Description

Use thenComposeAsync when the next step is itself asynchronous. The callback runs on the async executor and must return a Future. The outer Future completes with whatever the inner Future produces.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.thenComposeAsync(function)

Parameters

ParameterDescription
functionRequired. A function that takes the previous result and returns a Future.

See also

thenCompose

Example

Nested async step (from product tests).

<cfscript>
    future = runAsync(function() { 
        return 5; }).thenComposeAsync(function(x) 
        {        return runAsync(function() { return x * 2; });    }).thenApplyAsync(function(x) {        return x + 10;    });
    writeOutput(future.get()); // 20
</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