Quellcode durchsuchen

Made EventWindow into a singleton.

dev-tmpl
Bryan Miller vor 6 Jahren
Ursprung
Commit
0d889a8342
1 geänderte Dateien mit 11 neuen und 2 gelöschten Zeilen
  1. +11
    -2
      app/js/ui/EventWindow.js

+ 11
- 2
app/js/ui/EventWindow.js Datei anzeigen

@@ -1,4 +1,4 @@
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
@@ -6,9 +6,12 @@ import '/app/js/EventCaller.js'
*
* Users should not directly set the window event handler functions if using this class.
*/
export class EventWindow extends EventCaller{
class EventWindow extends EventCaller{
constructor(){
super();
if (!EventWindow.instance)
EventWindow.instance = this;
return EventWindow.instance;
}

listen(eventName, callback, owner=null, once=false){
@@ -53,3 +56,9 @@ export class EventWindow extends EventCaller{
return this;
}
}


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


Laden…
Abbrechen
Speichern