Using MicroEvent.js
MicroEvent.js is an event emitter library, which provides the observer pattern to JavaScript objects. We need MicroEvent.js for triggering events from stores to update views.
You can get MicroEvent.js from http://notes.jetienne.com/2011/03/22/microeventjs.html.
To make an object or constructor be able to emit events and others to be able to subscribe to it, we need to integrate a MicroEvent
interface into the object or constructor using the MicroEvent.mixin
method.
Now, inside the object or constructor, we can trigger events using this.trigger()
, and others can subscribe to events using the bind()
method of the object. We can also unbind using the unbind()
method.
We will look at example code while building the RSS feed reader.