Created
April 26, 2021 12:40
-
-
Save angeenes/c6f4e71e4f46fe83dde6e905681cc4c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @class | |
* @name App | |
* | |
* @description Instance the main application | |
*/ | |
class App { | |
/** | |
* @constructor | |
* @description create and return a App instance | |
*/ | |
constructor() { | |
if (!App.instance) { | |
this.datas = {} // examples d'utilisation | |
this.userAgent = navigator.userAgent.toLowerCase() // examples d'utilisation | |
this.version = 'v0.0.1 - name' | |
App.instance = this | |
this.init() | |
} | |
return App.instance | |
} | |
/** | |
* @name init | |
* @description init the App | |
*/ | |
init() { | |
this.exampleMethod() | |
this.exampleMethod2() | |
} | |
/** | |
* @name exampleMethod | |
* @description an example method | |
*/ | |
exampleMethod() { | |
console.log('example method 1') | |
// ... | |
} | |
/** | |
* @name exampleMethod2 | |
* @description another example method | |
*/ | |
exampleMethod2() { | |
console.log('example method 2') | |
// ... | |
} | |
} | |
window.addEventListener('DOMContentLoaded', () => { | |
const instance = new App() | |
Object.freeze(instance) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment