How to write the observer pattern in JavaScript | Hacker News Reader