Methods
emit(name, dataopt)
Fires a new single event for this emitter.
If a listener was registered with the "once" flag
then it will only be fired once, then removed
from the listeners list.
Additional data can be added by an exact single second
argument. Use an object if you have complex data to
submit during the event.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | name of the event | |
data |
any |
<optional> |
optional data |
- Source:
off(nameopt, fnopt)
Remove listeners. Has multiple combinations:
- if no arg at all is passed will remove **everything**
- if only name is passed will remove all listeners by name
- if name and function is passed will remove only this specific
listener, if it has been attached before
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string |
<optional> |
|
fn |
function |
<optional> |
- Source:
on(name, fn)
Attach a new listener
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
fn |
function |
- Source:
once(name, fn)
Fires a listener exactly once and then removes it
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
fn |
function |
- Source: