Monthly Archive: July 2014

JavaScript: Observer Pattern / Publish-Subscribe

In this post, I will describe how to create a reusable implementation of the Observer pattern (also known as Publish-Subscribe or Dependents (1)). This implementation can be applied to any JavaScript object to instantly make it observable! The implementation can also be used to create a global topic registry. First, what is the Observer Pattern? The Observer Pattern, as described by the ‘Gang of Four’, defines a one to many dependency...