You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is it safe to use Napi::Addon and Napi::ObjectWrap together? #1097
I have an addon which contains most methods on class inherited from Napi::Addon, and i have another class (SimpleObject in this example) whose lifetime needs to be bound to JS code. Is it safe to use it like in the example below, or there is a better alternative? Thx.
@Patick-BatemanNapi::Addon uses env.SetInstanceData() internally, so setting the constructor as the instance data will overwrite Napi::Addon's data. You will want to store the persistent reference to the constructor as an instance variable of your SimpleAddon class:
Activity
gabrielschulhof commentedon Nov 5, 2021
@Patick-Bateman
Napi::Addonusesenv.SetInstanceData()internally, so setting the constructor as the instance data will overwriteNapi::Addon's data. You will want to store the persistent reference to the constructor as an instance variable of yourSimpleAddonclass:doc: add blurb about SetInstanceData
doc: add blurb about SetInstanceData
doc: add blurb about SetInstanceData
doc: add blurb about SetInstanceData
doc: add blurb about SetInstanceData