目录

Creating a Strong Reference to an ArkTS Object Using Node-API Extension APIs

HarmonyOS provides the napi_strong_ref APIs to create strong references, which is more efficient than the napi_ref APIs.

When to Use

You can use the napi_create_strong_reference API to create a strong reference to an ArkTS object and use the napi_get_strong_reference_value API to obtain the referenced ArkTS object.

Available APIs

API Description
napi_create_strong_reference Creates a strong reference to an ArkTS object.
napi_delete_strong_reference Deletes a strong reference.
napi_get_strong_reference_value Obtains the ArkTS object value associated with a strong reference object.

Sample Code