napi_make_callback

Function napi_make_callback 

Source
pub unsafe extern "C" fn napi_make_callback(
    env: napi_env,
    async_context: napi_async_context,
    recv: napi_value,
    func: napi_value,
    argc: usize,
    argv: *const napi_value,
    result: *mut napi_value,
) -> napi_status
Available on crate features napi and api-11 only.
Expand description

Allows an ArkTS function to be called in the asynchronous context. The capabilities related to ‘async_hook’ are not supported currently.

§Arguments

  • env - Current running virtual machine context.

  • async_context - The context environment for the async operation.

  • recv - The ‘this’ pointer of the function.

  • func - ArkTS function to be called.

  • argc - Size of the argument array which is passed to ‘func’.

  • argv - Argument array.

  • result - Result returned by the ArkTS function.

§Returns

  • Returns the function execution status. [napi_ok] If the function executed successfully.

[napi_invalid_arg] If the param env, func and(or) recv is nullptr;

If the param argc is greater than 0 but argv is nullptr.

[napi_object_expected] If the param recv is not an ArkTS Object.

[napi_function_expected] If the param func is not an ArkTS Function.

[napi_pending_exception] There is an uncaught exception occurred before(in) execution.

Available since API-level: 11