Skip to content

Nan::Callback SetWeak #891

Open
Open

Description

@Lokomojo

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?

Activity

  1. bnoordhuis commented on May 26, 2020

    @bnoordhuis
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions