micro-mediator
A super tiny mediator for use with the publisher/subscribe pattern. Uses the Map datatype. Reverts to plain objects in older browsers.
Use with browserify/webpack or just include and it'll install on window
.
Call .subscribe()
or .on()
to listen to events,
.unsubscribe()
or .off()
to unlisten,
and .publish()
, .emit()
, or .trigger()
to fire events.
var Mediator = var mediator = mediator mediator mediator
Or install the mediator to objects of interest.
var o = {}var m = m o o
If you'd rather just install Mediator to an object rather than make instances, just pass this method a variadic number of objects:
Mediator var bob = {} bob bob
This will install a new mediator instance on each object you pass.
You can also install to a single instance:
Mediator