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

thenApplyAsync (Future method)

Last update:
May 18, 2026
After this Future succeeds, runs your function on the async executor and returns a new Future with the transformed value.

Description

thenApplyAsync runs the callback on a worker thread from the ColdFusion async pool. The callback receives the successful result of the previous stage and must return the next value. ColdFusion preserves variable scope so closures can read variables and other scopes as in your tests.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.thenApplyAsync(function)

Parameters

ParameterDescription
functionRequired. A function that takes the previous result and returns the next value.

See also

thenApply (runs on the completing thread)

Example

Chain transforms and use outer scope inside the callback (from product tests).

<cfscript>
    variables.sharedValue = "test";
    result = runAsync(function() { 
        return 1; })    .thenApplyAsync(function(x) { return x + 1; })    .thenApplyAsync(function(x) { return x * 2; }).thenApplyAsync(function(x) {        return x & "_" & variables.sharedValue;    }).get();
    writeOutput(result); // 4_test
</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