Messagyjs example Messagyjs is easy!


We use on, add or subscribe methods to listen to an event and use off, remove or unsubscribe methods to remove our listener.

Then we can use trigger, broadcast or propagate or emit or publish methods to propagate an event and call all subscribing callbacks.



messagy was built for use in tiny to small sized projects and should be easy to replace with something more heavy-duty. different namings was used for the same methods so that you can use what ever that you are more familiar with/prefer/is more in sync with your future messaging library. A rule of thumb is that there are only three methods:

on("event name", callback) or add("event name", callback) or subscribe("event name", callback)
This method attaches a callback to an event (or channel) which is basically a string
trigger("event name") or broadcast("event name") or propagate("event name") or emit("event name") or publish("event name") (they may seem lexically inappropriate)
Which notifies all callbacks subscribing to the triggered event (or channel) to get executed
off("event name", callback) or remove("event name", callback) or unsubscribe("event name", callback)
Which removes the callback function from the subscribes list, if called with only event name will remove all subscribers from that event, if called without parameters will remove all subscribers from all events