For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/api/react.runonbackground.md.
这是开发预览网站。请访问正式文档 lynxjs.org

Home > @lynx-js/react > runOnBackground

runOnBackground() function

runOnBackground allows triggering js functions on the background thread asynchronously.

Signature:

export declare function runOnBackground<R, Fn extends (...args: any[]) => R>(f: Fn): (...args: Parameters<Fn>) => Promise<R>;

Parameters

Parameter

Type

Description

f

Fn

The js function to be called.

Returns:

(...args: Parameters<Fn>) => Promise<R>

A function. Calling which with the arguments to be passed to the js function to trigger it on the background thread. This function returns a promise that resolves to the return value of the js function.