OtherStuff: JSHackerNews

This app queries the Hacker News API through a proxy that mimics an unreliable server or a slow Internet connection. The app is written in vanilla JavaScript—no Vue, no React, no Angular, no jQuery. The only external libraries are polyfills for the new fetch API and the new promise API. Those two APIs are relatively new to the ECMAScript spec, so I judged the polyfills necessary.

    About This Widget

    I wrote a blog post about this widget here: https://adamcross.blog/2019/05/26/fetch-promise-observables/.

    I wrote this widget mainly to practice using the fetch API. Then I had occasion to use the promise API also. The code is available here: https://github.com/xerocross/js-hacker-news. You can easily see how much harder it would get if I needed a more complex app. Using a framework like Angular or Vue really helps to organize your code and separate business logic from view logic. I wanted to use something like RxJS's Observables here, but I didn't want to use RxJS of course because the whole point here was vanilla JS, so I wrote a tiny Observable class of my own. It's like 16 lines, and it does everything I need.