aboutsummaryrefslogtreecommitdiffstats
path: root/src/EventTarget.js
blob: c762929612e3d834fff17854abd9a5c5d7102261 (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
import {on, off, dispatch} from './event.js'

export default class EventTarget {
  // Bind given event to listener
  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
  }

  dispatch (event, data) {
    return dispatch(this, event, data)
  }

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