I got bored last night so started trying to implement Promises in Lucee based on the Promises/A+ specification. A day later and I have a working extension, so that’s nice.

The source can be found over on github ( SimonHooker/lucee-promise ). If you just want to grab the lex file, the current version is extension-lucee-promise-1.0.0.57.lex. Just download it and drop it into your contexts deploy folder and you’re good to go.

All things considered, PromiseJS API documentation and Promise on MDN both cover how to use this quite well. The only differences are as follows:

  • In Lucee the promise at present does not automatically update itself with the resolved value. To retrieve the final value you must use promise_object.value()
  • Instead of Promise.resolve( ... ) you must use Promise::resolve( ... )
  • Instead of Promise.reject( ... ) you must use Promise::reject( ... )
  • Instead of Promise.all( [ ] ) you must use Promise::all( [ ] )
  • Instead of Promise.race( [ ] ) you must use Promise::race( [ ] )

So there you have it, Promises in Lucee, hope you all have fun with them!

Strayegg

I'm Simon Hooker and have been working as a developer since 2007. I'm currently the Technical Lead at My School Portal. Nowadays I mostly work with NodeJS, Lucee, AWS, and all sorts of other bits and bobs.

Outside of work I enjoy getting out sailing whenever I can (preferably somewhere warm.) I'm a big fan of Terry Pratchetts books. And Lego. I love Lego.

  • Twitter
  • LinkedIn
  • Github
  • Bitbucket
  • stackoverflow