aboutsummaryrefslogtreecommitdiffstats
path: root/src/EventTarget.js
blob: ce18d1f4720345fcb38672db9fc363257c1f5c90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 || {}
}

  // Bind given event to listener
export function on (event, listener, binding, options) {
  _on(this, event, listener, binding, options)
  return this
}

  // Unbind event from listener
export function off (event, listener) {
  _off(this, event, listener)
  return this
}

export function dispatch (event, data) {
  return _dispatch(this, event, data)
}

  // Fire given event
export function fire (event, data) {
  this.dispatch(event, data)
  return this
}