On Wed, Feb 12, 2020 at 2:31 PM Darin Dimitrov <darin.dimit...@gmail.com> wrote: > > I managed to get this working by replacing the native Promise object by > executing the following script: > > global.Promise = new Proxy(global.Promise, { > construct: function(target, args) { > const origFunc = args[0]; > return new target(function(resolve, reject) { > origFunc( > value => executeOnMainThread(resolve.bind(this, value)), > reason => executeOnMainThread(reject.bind(this, reason)) > ); > }); > } > }); > > In this example, I have registered the "executeOnMainThread" function on the > global object which will call the specified js function argument on the main > thread. > > Of course if this can be achieved without replacing the global Promise > object, that would be even better.
I don't think V8 lets you do that right now. There's isolate->SetPromiseHook() but that's intended more for tracing/logging than for intercepting. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CAHQurc_-5tMKs22kqzFGemO6oqhc584RxaWxMio-xehfciS1bw%40mail.gmail.com.