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

Ork: SSH Server Automation in Go

Ork: SSH Server Automation in Go

Read Article
Deno Deploy Killed My Start Page

Deno Deploy Killed My Start Page

Read Article
Back to Golang: Why I Switched From Static to Dynamic Again

Back to Golang: Why I Switched From Static to Dynamic Again

Read Article
View All Blog Posts