Hacker News new | past | comments | ask | show | jobs | submit login

It helps syntactically but does nothing about the main problem: composability. Each of your functions has to know which function to call next, instead of just having one function that invokes n other functions in order. That's what next() is meant for.

For composability in JS I use small utility modules like "inOrder":

  function beforeWifeComesHome() {
    function takeTheTrashOut() {
      inOrder([openDoor, goOut, emptyTrash, goIn, closeDoor]);
But it would be easier to let the compiler take care of the async calls and insert callbacks automatically so that you can think synchronously while the program works asynchronously. And if you want to run stuff in parallel you should use child processes.

Applications are open for YC Winter 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact