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

thenApply

Last update:
May 18, 2026
After this Future completes normally, runs a function on the completing thread that maps the result to a new value.

Description

thenApply is an instance method on a CFML Future (for example a value returned from runAsync). When the previous stage completes successfully, your function runs on the completing thread and returns the next value. The method returns a new Future that completes with that mapped value.
This is the synchronous counterpart to thenApplyAsync, which runs the mapper on the async executor. Use thenApply for short, CPU-light mapping that should not incur an extra async hand-off.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.thenApply(function)

Parameters

ParameterDescription
functionRequired. A function that accepts this stage’s result and returns the mapped value.

Example

Map a numeric result on the completing thread.

<cfscript>
    future = runAsync(function() { return 5; });
    mapped = future.thenApply(function(x) { return x * 2; });
    writeOutput(mapped.get()); // 10
</cfscript>
      

See also

thenCompose

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