JQuery. Event Bus

This is a very short snippet for a JQuery event bus with subscribe, unsubscribe, and publish methods.

JQuery. Event Bus

This is a vey short snippet for a JQuery event bus:


var EventManager = {
    subscribe: function(event, fn) {
        $(this).bind(event, fn);
    },
    unsubscribe: function(event, fn) {
        $(this).unbind(event, fn);
    },
    publish: function(event) {
        $(this).trigger(event);
    }
};
← Previous
Laravel. How to Clean Temporary Files
Next →
Critical Thinking in Programming

Keep Reading

Explore more articles and insights

uid: SafeShortID and HexShortID — Time-Ordered IDs Without the Rude Words

uid: SafeShortID and HexShortID — Time-Ordered IDs Without the Rude Words

Read Article
Bootlegance: 70 Free Bootstrap 5 Themes with Native Dark Mode

Bootlegance: 70 Free Bootstrap 5 Themes with Native Dark Mode

Read Article
A Big, Opinionated List of PHP Libraries (2026 Edition)

A Big, Opinionated List of PHP Libraries (2026 Edition)

Read Article
View All Blog Posts