CallbackScope

There are cases (for example, resolving promises) where it is necessary to have the equivalent of the scope associated with a callback in place when making certain N-API calls.

Methods

Constructor

Creates a new callback scope on the stack.

cpp Napi::CallbackScope::CallbackScope(napi_env env, napi_callback_scope scope);

Constructor

Creates a new callback scope on the stack.

cpp Napi::CallbackScope::CallbackScope(napi_env env, napi_async_context context);

Destructor

Deletes the instance of Napi::CallbackScope object.

cpp virtual Napi::CallbackScope::~CallbackScope();

Env

cpp Napi::Env Napi::CallbackScope::Env() const;

Returns the Napi::Env associated with the Napi::CallbackScope.

Operator

cpp Napi::CallbackScope::operator napi_callback_scope() const;

Returns the N-API napi_callback_scope wrapped by the Napi::CallbackScope object. This can be used to mix usage of the C N-API and node-addon-api.