Ebisu Tutorial

The basics

The Ebisu system solves one request: Custom Event. A "Custom Event" is, of course, an event. However they are defined by programmers instead of system. System event refers to those trigger by runtime environment, for example, javascript engine in a browser.

For a quick start, here's a hello world example of Ebisu (in favor of jQuery's $ function):

Ebisu("user is here").to("#salut").attach(function() {
    $(this).html("Hello world");
});

$(document).ready(function() {
    Ebisu("user is here").trigger();
});

In this example, the first statement declare an event named "user is here". Yes, you may use any string as the event name, and it doesn't matter if your event named the same as those builtins, like "mouseover". Ebisu event are totally unrelated to standard DOM events. The second statement trigger that event when DOM is ready. So user can see the "Hello world" if $("#salut") can grab any element.

The last sentence is an important feature in Ebisu core. If the css query "#salut" gives you no elements at all, it doesn't break. If it does, then it'll work, but if it does not, your application remains steady. Which means you are basically free to remove elements from DOM if required, and not having to worried about removing corresponding event handlers. Ebisu can know that the query "#salut" grabs nothing, and not even call the handler.

You may think it as a way to indirectly call functions, in fact it's really what it does.