Proposal: use "One More Point" to handle async functions

Li Xiaolong 898310778 at
Tue Sep 27 14:09:31 UTC 2016

The traditional callback method to handle async is not elegant and clear.
Even the promised style is kind of odd. So I got an idea that we use "One
More Point"(OMP) to make async coding easier to use. For example: 


//Without One More Point:

function async(args, callback) {


         obj.doSomeThing(function(result) {

                   obj2.doSomeOtherThing(result, function(result2){





async([1,2,3], function(result) {






//With the help of One More Point:

function async(args) {


         .return obj2..doSomeOtherThing(obj..doSomeThing());





So, in general, the OMP makes async coding looks like sync coding. The
return value of a function called with OMP will return the value after the
".return" keyword. The code after the OMP call will all be delayed until the
async ends. This sounds like the code is blocked, but actually it's
non-blocking, as the user can still interact with the interface and the cpu
is sleeping. There is one limitation that OMP style can only replace
callback style async calls that are at the end of a function, since there is
no more code after the async function is called. However, as far as I can
see, about half or more async functions are at the end of a function. So,
the OMP is significant.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list