11
AllenII
8y

Was wondering why my callback wouldn't run when I intended.
> console.log each iteration
> realizes it skips the goal and goes up one
> decided to cheat use greater than instead
> ACCIDENTAL RECURSION
> Oh, there's the problem
> Thinks about going to bed for the night

Comments
  • 3
    I know this is not StackOverflow but, dare I say it, this is shite code!
  • 0
    @GinjaNinja well I'm tired, and tired of looking at it myself. But criticism doesn't hirt me, and you're right when you say this isn't SO--precisely why i see no problem with asking you to elaborate. I'm all for learning better
  • 0
    @rtannerf i definitely agree with the }))), i don't like seeing it either.

    The recursion was very much accidental. I meant to put cb() but typed isDone() in my inattentiveness without even noticing.

    getUsers() is using JSONP to query the twitch.tv api. Once all users were fetched, another function goes off to get additional info; i wanted an explicit way to run a callback once getUsers() was done (hence the name) instead of relying on getUsers() to always be faster.

    Anywho, what name would you prefer as opposed to isDone ? And i formatted my shit better since taking the screenshot
  • 1
    @AllenII
    I don't know if this what you're trying to do, but have a look at Promises 😉
  • 1
    @GinjaNinja i know promises a bit, but thanks for the suggestion because i didn't think of that. But i understand that promises are for a single request and response--is there some way that you know of that a promise can wait on several requests to finish? That would be an observable, wouldn't it? Just asking for future endeavours.
  • 1
    @rtannerf. I'll look into those, thank you so much for the nuggets
  • 1
    What @rtannerf said! 😎 You will certainly be able to find and accomplish what you need with Promise.all() and Array.map().

    Good luck and happy learning!
Add Comment