Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
balte22917yPromise you will resolve this someday, and not reject JavaScript's beautiful asynchronous nature!
-
joas18917y@balte
Node.js using Promises on all core modules out of the box. That's a heck of a dream.
But I certainly hope that we get to resolve that promise. Every JS developer should know about the wonders of the mother of all frameworks that is not a callback hell.
Promises and async / await (if you prefer). -
And don't throw exceptions in callbacks, then effectively assume success and carry on in the main body.
-
Codazed14477ySpecifically, this is the callback I'm having an issue with. I know that this is a horrible spot to put it, but it's the only place I could figure out where to put it that it would work. If it's not inside that for loop, it'll execute before the for loop finishes. Any ideas?
-
@BaconatorNoVeg The callback will need to be inside of getPlaylistVideos, but doesn't have to be inside the for loop. Define it just before the for loop and give it a name. Then pass the function to getSongData by name.
cb is getting called multiple times either way, however. This is normally a bad thing. I'd do something with the 'async' library, personally.
When it feels impossible to get your javascript callback to happen at the right time, so you just throw the callback somewhere just so it works, but you know that it's not the ideal spot for it... 😡😡😡
🖕💻
rant
javascript
nodejs
callbacks