I’m using haxe-continuation – which I’ve found to work really well. It’s a single-purpose macro (instead of the big tink library), and can automatically wrap e.g. extern JS functions which take a callback as their last parameter. Note that the license is not MIT.
I’m going to talk about using it in my upcoming Haxe Summit talk.
It’s a slick macro that actually breaks your “synchronously-written functions” into multiple functions and callbacks, while maintaining scoped variables. Basically it’s re-writing your synchronous code as a set of asynchronous functions. It also has the interesting side effect of being able to assign multiple variables (because a callback function – which this is translated into – can take multiple parameters):
It’s also awesome that Haxe macros enable this kind of power.
It’s not perfect, though. It doesn’t provide any error handling options (e.g. optionally insert try/catch), and there aren’t any comments. But, it works for now.