Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nan::Callback SetWeak #891

Open
TomMettam opened this issue May 17, 2020 · 1 comment
Open

Nan::Callback SetWeak #891

TomMettam opened this issue May 17, 2020 · 1 comment

Comments

@TomMettam
Copy link

TomMettam commented May 17, 2020

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants