napi_create_reference

Function napi_create_reference 

Source
pub unsafe extern "C" fn napi_create_reference(
    env: napi_env,
    value: napi_value,
    initial_refcount: u32,
    result: *mut napi_ref,
) -> napi_status
Available on crate feature napi only.
Expand description

Creates a reference for an object to extend its lifespan. The caller needs to manage the reference lifespan.

§Arguments

  • env - Current running virtual machine context.

  • value - The napi_value that is being referenced.

  • initial_refcount - The initial count for the new reference.

  • result - napi_ref pointing to the new reference.

§Returns

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

[napi_invalid_arg] If env, value or result is nullptr.

Available since API-level: 10