jatazoulja
jatazoulja

Reputation: 105

Javascript: tracing custom events

Is there a way to trace custom events, specially those non-DOM events like in backbone?

thisObj.on("custom:triggeredEvents", function() { do.stuffHere() });
thisObj.trigger("custom:triggeredEvents");

Cheers!

Upvotes: 0

Views: 194

Answers (1)

Martin Lantzsch
Martin Lantzsch

Reputation: 1901

You should have a look at the observer pattern.

If you don't want to implement this by yourself, you can use existing libraries, e.g. https://github.com/mroderick/PubSubJS

Upvotes: 2

Related Questions