2

I am using quickjs js engine. As a part of my requirments, I wanted to create a Promise and do certain actions when its resolved or rejected. (Basically do set then and catch functions). I know promise is created as such:

JSValue resolvingFuncs[2];
JSValue promise = JS_NewPromiseCapability(ctx,resolvingFuncs);

The two resolving functions be the resolve and reject. But how do I set then and catch functions ?

Anurag Vohra
  • 1,781
  • 12
  • 28
  • `then` and `catch` are methods on the promise object. – Abrar Hossain Dec 03 '22 at 12:00
  • @AbrarHossain yes they are. But they are called automaically when Promise is resolved and rejected. I wanted a way to pass functiosn to `then` and `catch` from the C side. I am implemneting writable stream and as a part of specification oneed to create a promise and do certain task upon its completion or rejection. – Anurag Vohra Dec 03 '22 at 14:22
  • @AbrarHossain yes treating it that way worked!. Thank you. – Anurag Vohra Dec 04 '22 at 01:14

0 Answers0