Skip to content

Instantly share code, notes, and snippets.

@angeenes
Created April 26, 2021 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angeenes/c6f4e71e4f46fe83dde6e905681cc4c5 to your computer and use it in GitHub Desktop.
Save angeenes/c6f4e71e4f46fe83dde6e905681cc4c5 to your computer and use it in GitHub Desktop.
/**
* @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