Should I rewrite the JS for my Twitch App using promises?

Should I rewrite the JS for my Twitch App using promises?
0.0 0

#1

I just finished today: https://codepen.io/ellereeeee/pen/eBZmKr

I used setTimeout(); to deal with the asynchronous nature of the get requests. No very elegant, but it works alright.

I found out today that promises or web workers are probably better solutions.

I’d really like to move on, but was wondering if it was worth sucking it up and rewriting my JS with promises for my Twitch App. Thanks for any suggestions.


#2

I wouldn’t say that you need to use promises, but I would definitely get rid of the setTimeout. It’s natural to want to use it in this case, but there is zero chance you would ever do this in production, so it’s best to learn how to deal with asynchronicity now. The good news, though, is that most of your code is fine and dandy. While promises are absolutely the best way to go here, you could simply rethink how and when you render your HTML. Check out this awesome video on using jQuery with Handlebars.

If you’re really burnt out, I suggest you go onto the next project, but plan on refactoring this one.


#3

Thank you for sharing your insight and suggestions!

If promises are the way to go, then I’ll go ahead and grind through it.