50

Dear javascript, you think you're sooooo fucking special. You just HAD to be asynchronous everywhere, losing all connections to natural sequential human thinking. I just want to work with the result of A GOD DAMN FOR LOOP you ASYNC FUCK.

Comments
  • 0
    @Flarp it's a for loop with one ajax call per iteration, and the ajax return appends to a global array. I want to use the global array in another function, I can probably do it with callbacks but will most likely just do it in PHP since it doesn't need to be client side
  • 7
    JavaScript is mostly single threaded and blocking, except for I/O and UI stuff that has been moved out of the mainthread

    But God help us if I/O like Ajax weren't async. The web would truly suck ...

    Have you looked at promises and promises.all()? Or is jQuery.when() available?

    You could easily create a promise which waits for all Ajax calls to complete before executing.

    I know you said it doesn't need to be done in the client side this time, but next time it might ...
  • 3
    Promise.all(urlsyouwanttofetcharr.map(fetchsingleurl))
  • 0
    Events bro! Event listeners!
  • 3
    Well, don't get me started on PHP.
  • 2
    @eshwarenm PHP is so beautiful 🙄
  • 1
    @rsynnest like seriously? Imagine the world with synchronous ajax. Its not the world lenon asked us to dream about.
    Here for loop itself is sync. Its the call that's async.
    Look into promises. They are promising.
  • 0
    Promise me that you'll keep promises
  • 1
    @mhall oh async processing is fantastic, computing would be nightmarish without it and the web would suck without ajax, I just had to rant before diving back in. promise.all() is definitely the answer, though I will prob move it backend for other reasons.
  • 0
    @le-idiot hahaha. Touche.
  • 0
    async.js is good for this stuff
  • 0
    @d4ng3r0u5 I started with async.js but with native promises it has became obsolete IMO
Add Comment