diff options
Diffstat (limited to 'src/EventTarget.js')
-rw-r--r-- | src/EventTarget.js | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/EventTarget.js b/src/EventTarget.js index c762929..ce18d1f 100644 --- a/src/EventTarget.js +++ b/src/EventTarget.js @@ -1,25 +1,29 @@ -import {on, off, dispatch} from './event.js' +import {on as _on, off as _off, dispatch as _dispatch} from './event.js' + +export const name = 'EventTarget' + +export function setup (node = {}) { + this.events = node.events || {} +} -export default class EventTarget { // Bind given event to listener - on (event, listener, binding, options) { - on(this, event, listener, binding, options) - return this - } +export function on (event, listener, binding, options) { + _on(this, event, listener, binding, options) + return this +} // Unbind event from listener - off (event, listener) { - off(this, event, listener) - return this - } +export function off (event, listener) { + _off(this, event, listener) + return this +} - dispatch (event, data) { - return dispatch(this, event, data) - } +export function dispatch (event, data) { + return _dispatch(this, event, data) +} // Fire given event - fire (event, data) { - this.dispatch(event, data) - return this - } +export function fire (event, data) { + this.dispatch(event, data) + return this } |