Constructor
new Events()
- Source:
- Since:
- 0.1.0
Example
const event = new Event()
event.on("type", () => {})
Members
listeners :Object.<string, Array.<EventsListener>>
- Source:
Type:
- Object.<string, Array.<EventsListener>>
Methods
emit(type) → {void}
- Description:
events emit listener
- Source:
- Deprecated:
- 下一个大版本将会移除
Example
event.emit('click')
Parameters:
Name | Type | Description |
---|---|---|
type |
string | events type |
Returns:
- Type
- void
off(type, fnopt) → {void}
- Description:
events remove listener
- Source:
Example
event.off("click")
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | events type |
|
fn |
EventsListener |
<optional> |
events listener options |
Returns:
- Type
- void
on(type, fn) → {void}
- Description:
events add listener
- Source:
Example
event.on("click", () => {})
Parameters:
Name | Type | Description |
---|---|---|
type |
string | events type |
fn |
EventsListener | events listener |
Returns:
- Type
- void
once(type, fn)
- Source:
- Deprecated:
- events add once listener
Example
const fn = () => { console.log("emit once") }
event.once('click', fn)
Parameters:
Name | Type | Description |
---|---|---|
type |
string | events type |
fn |
EventsListener |
testFn(str) → {void}
- Description:
this is function
- Source:
Example
event.testFn("click", () => {})
Parameters:
Name | Type | Description |
---|---|---|
str |
string | gg param |
Returns:
- Type
- void