1. eve()
  2. eve.listeners()
  3. eve.nt()
  4. eve.off()
  5. eve.on()
  6. eve.once()
  7. eve.stop()
  8. eve.unbind()
  9. eve.version

Eve Reference

 eve(name, scope, varargs)

Fires event with given name, given scope and other parameters.

Arguments

name
string
name of the event, dot (.) or slash (/) separated
scope
object
context for the event handlers
varargs
...
the rest of arguments will be sent to event handlers

Returns: object array of returned values from the listeners

 eve.listeners(name)

Internal method which gives you array of all event handlers that will be triggered by the given name.

Arguments

name
string
name of the event, dot (.) or slash (/) separated

Returns: array array of event handlers

 eve.nt([subname])

Could be used inside event handler to figure out actual name of the event.

Arguments

subname
optional
string
subname of the event

Returns: string name of the event, if subname is not specified

or

Returns: boolean true, if current event’s name contains subname

 eve.off(name, f)

Removes given function from the list of event listeners assigned to given name. If no arguments specified all the events will be cleared.

Arguments

name
string
name of the event, dot (.) or slash (/) separated, with optional wildcards
f
function
event handler function

 eve.on(name, f)

Binds given event handler with a given name. You can use wildcards “*” for the names:

eve.on("*.under.*", f);
eve("mouse.under.floor"); // triggers f

Use eve to trigger the listener.

Arguments

name
string
name of the event, dot (.) or slash (/) separated, with optional wildcards
f
function
event handler function

Returns: function returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment.

Example:

eve.on("mouse", eatIt)(2);
eve.on("mouse", scream);
eve.on("mouse", catchIt)(1);

This will ensure that catchIt() function will be called before eatIt().

If you want to put your handler before non-indexed handlers, specify a negative value. Note: I assume most of the time you don’t need to worry about z-index, but it’s nice to have this feature “just in case”.

 eve.once(name, f)

Binds given event handler with a given name to only run once then unbind itself.

eve.once("login", f);
eve("login"); // triggers f
eve("login"); // no listeners

Use eve to trigger the listener.

Arguments

name
string
name of the event, dot (.) or slash (/) separated, with optional wildcards
f
function
event handler function

Returns: function same return function as eve.on

 eve.stop()

Is used inside an event handler to stop the event, preventing any subsequent listeners from firing.

 eve.unbind()

See eve.off

 eve.version

string

Current version of the library.