In Node.js v0.10.xx, calling a callback requires a Persistent<Function>.
Does anyone know to make the below code work in Node.js V12?
struct Baton {
uv_work_t request;
Persistent<Function> callback;};
somefunction() {
...
Baton *baton = new Baton();
baton->request.data = baton;
baton->callback = Persistent<Function>::New(Handle<Function>::Cast(args[0]));
uv_queue_work(uv_default_loop(), &baton->request, Work, AfterWork);..
}
void AfterWork(uv_work_t *req) {
Baton *baton = static_cast<Baton *>(req->data); HandleScope scope;
const int argc = 1;
Handle<Value> argv[argc] = { String::NewFromUtf8(isolate, "hello world") };
TryCatch try_catch;
*baton->callback->Call(Context::GetCurrent()->Global(), argc, argv); *
if (try_catch.HasCaught()) {
node::FatalException(try_catch);
}
baton->callback.Dispose();
baton->callback.Clear();
..
}
Thanks,
-Jake
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/03c2fc5d-86c5-4b00-b732-8841de2ea574%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.