tmt.notifier

This library implements the notifier/observer pattern in JavaScript using less than 1kb. The code was heavily inspired and partially based on Spry. While Spry uses inheritance to turn an object into a notifier, tmt.notifier is implemented as a decorator that adds the required methods to a given object at run-time

In order to properly use this library, familiarity with design patterns and solid JavaScript programming skills are required

In order to use this library you need tmt_notifier.js

Samples

API

In order to turn an object into a notifier you first have to call the decorator:

tmt.notifier.Decorator(obj) Adds the required methods to a given object at run-time and turn it into a notifier
Once an object becomes a notifier, it exposes the following methods:
obj.register(observer) Registers the given object as an observer
obj.unregister(observer) Unregisters the given object as an observer
obj.notify(methodName) Notify all the currently registered observers, invoking the specified method passing the notifier as an argument