This project has moved. For the latest updates, please go here.

# Promises with V8

 shrjain Aug 13, 2014 at 9:24 PM Edited Aug 13, 2014 at 9:25 PM Is there support for Promises/A like promises with Clearscript V8? (Chrome 32 has native support for promises, so I am assuming V8 does as well since chrome uses V8) Or if not, how does one use When.js or Task.js with Clearscript V8. Thanks! Shrainik ClearScript Coordinator Aug 14, 2014 at 1:53 PM Edited Aug 14, 2014 at 1:54 PM Hi Shrainik, ClearScript's current release has been tested with V8 3.24, which doesn't have built-in promises enabled by default. Unfortunately neither does V8 3.26, which is the target for ClearScript's next release. Until built-in promises are enabled in ClearScript, you should be able to use one of the available external implementations, perhaps with some modifications. Another possibility might be to leverage ClearScript's environment and implement the promise API pattern on top of .NET Tasks. Good luck! shrjain Aug 14, 2014 at 6:46 PM Edited Aug 14, 2014 at 6:46 PM The external implementation which I could find being closest to Promises/A proposal was task.js. But that relies on generators, which is again something which V8 3.24 doesn't support. Any other suggestions would be really helpful. Also, are there any recommended guidelines for loading external modules? Thanks, Shrainik ClearScript Coordinator Aug 15, 2014 at 2:44 AM Edited Aug 15, 2014 at 8:01 PM Hi again, Lie is one possibility. Using it with ClearScript requires no modifications and only minor setup: // setup engine.Execute(@" self = this; setTimeout = function (func, delay) { // add code here }; "); // run lie.js engine.Execute(File.ReadAllText(@"C:\path\to\lie.js")); // create a promise engine.Execute(@" x = new Promise(function (resolve, reject) { // add code here }); ");  You just need to provide a setTimeout() function that works with your application's async model. As for modules, ClearScript doesn't define or depend on any particular solution, as it provides only low-level script engine integration. With .NET facilities at its disposal, the host should be able to implement or reuse whatever packaging scheme it requires. However, because existing implementations often assume a browser or Node.js environment, the host may have to provide a bit of plumbing. You can find a RequireJS example here, and one that sets up a CommonJS environment here. Cheers! shrjain Aug 15, 2014 at 4:30 PM Thanks! Let me try this out.