Просмотр исходного кода

Made EventWindow into a singleton.

dev-tmpl
Bryan Miller 7 лет назад
Родитель
Сommit
0d889a8342
1 измененных файлов: 11 добавлений и 2 удалений
  1. +11
    -2
      app/js/ui/EventWindow.js

+ 11
- 2
app/js/ui/EventWindow.js Просмотреть файл

import '/app/js/EventCaller.js'
import {EventCaller} from '/app/js/EventCaller.js'


/** /**
* Wraps the browser's window object around the EventCaller allowing the user to connect to system events * Wraps the browser's window object around the EventCaller allowing the user to connect to system events
* *
* Users should not directly set the window event handler functions if using this class. * Users should not directly set the window event handler functions if using this class.
*/ */
export class EventWindow extends EventCaller{
class EventWindow extends EventCaller{
constructor(){ constructor(){
super(); super();
if (!EventWindow.instance)
EventWindow.instance = this;
return EventWindow.instance;
} }


listen(eventName, callback, owner=null, once=false){ listen(eventName, callback, owner=null, once=false){
return this; return this;
} }
} }


const instance = new EventWindow();
Object.freeze(instance);
export default instance;


Загрузка…
Отмена
Сохранить