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
I need to store V8 callbacks as weak references, with the finalizer callback so I can remove the reference when appropriate.
I've worked out how to do this with v8::Function, but I was hoping to keep the Nan::Callback wrapper intact in case of future API changes. Unfortunately the documentation is quite bare.
Nan::Persistent<v8::Function>::SetWeak() coupled with Nan::Call() to actually invoke the function should do it.
Nan::Callback could in theory be extended to offer that functionality (internally it already uses a Nan::Persistent<v8::Function>) but I don't know, that's probably too esoteric and uncommon. A Nan::Callback is usually embedded in some other weak object.
Activity
bnoordhuis commentedon May 26, 2020
Nan::Persistent<v8::Function>::SetWeak()coupled withNan::Call()to actually invoke the function should do it.Nan::Callbackcould in theory be extended to offer that functionality (internally it already uses aNan::Persistent<v8::Function>) but I don't know, that's probably too esoteric and uncommon. ANan::Callbackis usually embedded in some other weak object.