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

Are you saying it would be good for them to block? Why?

When they execute, they run a callback with the input provided. Inside that callback, do whatever you need to do that requires some input.

Confirm and prompt are typically used to indicate a decision by the user. Natively, these functions stop javascript execution to wait for the users input, so that it knows what to do, but do not allow for customization. Non-native libraries do not have this ability to prompt the user for input, then wait for their response, before continuing the execution of that script. Callbacks are one way to circumvent this issue, but introduce new issues with scope and readability.

All I'm trying to say is that allowing custom defined objects to have the ability to block execution can be very handy in certain instances. I by no means was criticizing the alertify.js library

Sometimes it's just easier to have linear code with some blocking than to create an entire state machine. Yes there are libraries that get close to this. No, it's still not the same.

You can have linear code without blocking - it's exceptionally common in the node world.

async.waterfall([ function getInput(){...}, function checkInput(){...}, function submitInput(){...}, ], function finally(){})

Each of the functions takes a callback, and returns err (if any) and output. If a callback returns err, it jumps to finally where you say what failed.

This is odd when you first get started with async, but it's really easy to visualize.

Think of a production line, with a number of different workers doing different stuff. If one of them gets a dud part, it throws it away.

I get it. I do plenty of async programming. But, at the end of the day, no matter how nice you think the async.waterfall mess is, sometimes you just want to block. Sometimes it turns out that that is the right pattern. I've written dozens of async apps, much to the chagrin of co-workers who hate anything resembling async. I think I'm qualified to know that sometimes I get to a bit of code that sure would be nice with a simple blocking call.

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