Skip to content

Adds custom events to Javascript. This is an implementation of the Observer design pattern in Coffeescript. Fully TDD'd

Notifications You must be signed in to change notification settings

c9952594/jsEvents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

USAGE:

CoffeeScript:

First create an event

event = new jsEvents.Event

Register a function. This will return an observer object. You can use this to unregister the event or register for more events to the same observer

observer1 = event.register (name) -> alert name

Or you can create and register the observer yourself. This could be useful if you want to register to many events.

observer2 = new jsEvents.Observer (name) -> alert name + " Smith" event.register observer2

Kick off the event

event.notify "Craig"

Unregister one of the events

event.unregister observer1 event.notify "Another"

Javascript:

/* First create an event */ event = new jsEvents.Event;

/* Register a function. This will return an observer object. You can use this to unregister the event or register for more events to the same observer */ observer1 = event.register(function(name) { return alert(name); });

/* Or you can create and register the observer yourself. This could be useful if you want to register to many events. */ observer2 = new jsEvents.Observer(function(name) { return alert(name + " Smith"); }); event.register(observer2);

/* Kick off the event */ event.notify("Craig");

/* Unregister one of the events */ event.unregister(observer1); event.notify("Another");

About

Adds custom events to Javascript. This is an implementation of the Observer design pattern in Coffeescript. Fully TDD'd

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published