Front end of the Slack clone application.

event_target.js 624B

1234567891011121314151617181920212223242526272829
  1. var Event = require('./event');
  2. var EventTarget = {
  3. onopen: null,
  4. onmessage: null,
  5. onerror: null,
  6. onclose: null,
  7. addEventListener: function(eventType, listener, useCapture) {
  8. this.on(eventType, listener);
  9. },
  10. removeEventListener: function(eventType, listener, useCapture) {
  11. this.removeListener(eventType, listener);
  12. },
  13. dispatchEvent: function(event) {
  14. event.target = event.currentTarget = this;
  15. event.eventPhase = Event.AT_TARGET;
  16. if (this['on' + event.type])
  17. this['on' + event.type](event);
  18. this.emit(event.type, event);
  19. }
  20. };
  21. module.exports = EventTarget;