import ngModule from '../module'; /** * The main application class. * * @property {String} name The application name. * @property {Snackbar} snackbar The main object to show messages. */ export default class App { constructor($rootScope) { this.loaderStatus = 0; this.$rootScope = $rootScope; } show(message) { this.timeout = window.snackbarTimeout || 2000; if (this.snackbar) this.snackbar.show({message: message, timeout: this.timeout}); } showMessage(message) { this.show(message); } showError(message) { this.show(`Error: ${message}`); } pushLoader() { this.loaderStatus++; if (this.loaderStatus === 1) this.$rootScope.loading = true; } popLoader() { this.loaderStatus--; if (this.loaderStatus === 0) this.$rootScope.loading = false; } } App.$inject = ['$rootScope']; ngModule.service('vnApp', App);