Nan::Callback SetWeak
TomMettam opened this issue · 1 comments
TomMettam commented
Hey.
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.
Is there a way to do this?
bnoordhuis commented
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.