Mu icon indicating copy to clipboard operation
Mu copied to clipboard

Asynchronous lambda support

Open juliangoacher opened this issue 13 years ago • 0 comments

Consider adding asynchronous lambda support? It would work as follows:

  • Function values would support an optional callback argument.
  • Function values accepting the callback would return an undefined value and pass the template value at a later stage using the callback.
  • Function values will continue to work synchronously if they returning a value.

The solution would look like this:

var data = {
    value: function( body, cb ) {
        process.nextTick(function() {
            cb('result');
        });
    }
}

I've implemented a solution here: https://github.com/juliangoacher/Mu/commit/599ea69561372a95d2b659dba36aa60df1e10057

The solution will inspect the arity of a value function to try and avoid the situation where a function which doesn't accept the callback returns undefined and so hangs the process.

juliangoacher avatar Aug 22 '12 16:08 juliangoacher