Skip to content

Make callback optional in ThreadSafeFunction::New #859

@seishun

Description

@seishun

Napi::ThreadSafeFunction::New has a required Napi::Function parameter which I don't need in my use case. I can't use Napi::TypedThreadSafeFunction since I need to use a different callback across calls to [Non]BlockingCall().

https://github.com/nodejs/node-addon-api/blob/48e6b584a396ee5c42ef971c216139ad454f478b/doc/threadsafe.md states the following regarding Napi::ThreadSafeFunction:

This API is designed without N-API 5 native support for the optional JavaScript function callback feature. ::New methods that do not have a Function parameter will construct a new, no-op Function on the environment to pass to the underlying N-API call.

However, this doesn't appear to be the case.

I will gladly make a PR if this is something you're open to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions