Hacker Newsnew | comments | show | ask | jobs | submit login

    function getItem(id) {
      return $.get("/api/item/" + id);
    }
    $.when(getItem(3), getItem(4)).then(handleSuccess, handleFailure);
Maybe I'm taking the point of the example out of context here, but i worry that promises makes it too easy to write non thought through code like this. Why make two separate http-requests for something that should have been possible to do with one?

Future prediction: Someone will create code similar to the one above but inside a for-loop calling getItem hundreds of times instead of just 2.




You frequently don't control the API's your hitting. I've seen plenty of API's that don't support bulk operations.

I'm not sure I'm convinced if someone doesn't know how to do a bulk operation they're more likely to look because they've got an extra callback or two.

-----




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

Search: