First half working twitch app - Feedback please!


Could use some feedback:

I went around in circles trying to find a way to wait for all ajax calls to finish before starting to build the table.

I first make a call for “users” and then for “streams” and then I build the table.

I ended up making objects to store each user data, which doesn’t care in which order the users or streams calls end up finishing. And then I use $(document).ajaxStop(populatePage) to finnaly add everything to the page. Maybe by trying to make it in a smart way, I ended up creating a spagethi monster xD Perhaps a simple chain of callbacks for each user would have been better.

Here’s the code:

All feedback is welcome :slight_smile:

First: it looks really nice and it works too.

I looked at your code and I noticed you’ve mixed display code and code to fetch the data. That might be what got you into trouble.

I solved it by creating a simple JSON object which holds all the data I want to display in a format that is very similar whether online, offline or containing an error. Finally I call a function that displays this JSON object which only focuses on displaying the data.

In case you’re interested, here’s my version: my Twitch TV app