napi_call_function

Function napi_call_function 

Source
pub unsafe extern "C" fn napi_call_function(
    env: napi_env,
    recv: napi_value,
    func: napi_value,
    argc: usize,
    argv: *const napi_value,
    result: *mut napi_value,
) -> napi_status
Available on crate feature napi only.
Expand description

Invoke an ArkTS function. This is the primary mechanism to call back into JavaScript.

§Arguments

  • env - Current running virtual machine context.

  • recv - The this value passed to the called function

  • func - The ArkTS function to be invoked.

  • argc - The count of elements in the argv array.

  • argv - ArkTS values passed in as arguments to the function.

  • result - Whether the provided ‘type_tag’ is matched with the tag on the ArkTS object ‘value’.

§Returns

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

[napi_invalid_arg] If the param env and(or) func is nullptr. If argv is nullptr but argc greater

than 0.

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

[napi_pending_exception] If have uncaught exception, or exception occurred in execution.

Available since API-level: 10