Tag Archives: ufront

Transform js-style callback to Future with Haxe macro

EDIT (4 July 2016): A newer solution for this problem can be found at: https://github.com/kevinresol/futurize

Haxe macro is very powerful and it is really good at eliminating boiler-plate codes.

In the past 2 months I have been working on a web server using haxe/nodejs + ufront + mongoose (through js-kit). Since ufront supports async operations through Futures while mongoose uses js-style function callbacks, I have to write a lot of bolier-plate codes to convert the latter to the former, like this:

However, it is very cumbersome. If I have more than 100 database call like that, I have to write that code 100 times. Continue reading Transform js-style callback to Future with Haxe macro