-
Notifications
You must be signed in to change notification settings - Fork 17
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
emit event as thread safe callback #9
Comments
Hey, sorry for the late response, was on vacation… I think the problem might be that the callback is invoked before the listeners are attached. Could you check this? Put a printf inside the lamda before Also, N-API now has native support for what this project does, so it might be wiser to use that instead: |
Additionally, I think you need to use the receiver constructor of ThreadSafeCallback and provide |
Hi @mika-fischer, I am having a similar issue, could you please elaborate on this:
Thank you! |
If in JS you would do cb = () => val.emit() then in C++ you need to do: auto cb = make_shared<ThreadSafeCallback>(val, val.Get("emit").As<Function>()); // 2 arguments! Or conversely, if you do this in C++: auto cb = make_shared<ThreadSafeCallback>(val.Get("emit").As<Function>()); // 1 argument! it's like doing this in JS: cb = () => val.emit.call(undefined) |
Ok I see! I didn't know how to set the |
Hello, first thank you for publishing this module. I am trying to call the emit function on a ObjectWrapped class that inherits from EventEmitter, in which i am passing to ThreadSafeCallback the emit function. Stepping through the code I can see the cb->call(...) is getting called but the event is never making it back to the javascript side. Below is the code in question. Any help is welcome, thank you.
The text was updated successfully, but these errors were encountered: