Hi Jake It is worth reading strongloop blog:
http://strongloop.com/strongblog/node-js-v0-12-c-apis-breaking/ Regards On Tuesday, February 17, 2015, Jake Le <[email protected]> wrote: > > 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] > <javascript:_e(%7B%7D,'cvml','nodejs%[email protected]');>. > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nodejs/03c2fc5d-86c5-4b00-b732-8841de2ea574%40googlegroups.com > <https://groups.google.com/d/msgid/nodejs/03c2fc5d-86c5-4b00-b732-8841de2ea574%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Christian Taltas KPMG Technologies Services - Directeur Général [email protected] <[email protected]> +33 6 24 80 20 11 www <http://www.arpegeweb.com> +33 1 55 68 60 85 -- 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/CAEc8ZZaurtznN8aG0_rjyPJZegLfD8SererxG2oOzcTSqKM%3DFw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
