This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
fradrive-old/frontend/src/app.js

29 lines
836 B
JavaScript

import { HttpClient } from './services/http-client/http-client';
import { HtmlHelpers } from './services/html-helpers/html-helpers';
import { I18n } from './services/i18n/i18n';
import { UtilRegistry } from './services/util-registry/util-registry';
import { isValidUtility } from './core/utility';
export class App {
httpClient = new HttpClient();
htmlHelpers = new HtmlHelpers();
i18n = new I18n();
utilRegistry = new UtilRegistry();
constructor() {
this.utilRegistry.setApp(this);
document.addEventListener('DOMContentLoaded', () => this.utilRegistry.setupAll());
}
registerUtilities(utils) {
if (!Array.isArray(utils)) {
throw new Error('Utils are expected to be passed as array!');
}
utils.filter(isValidUtility).forEach((util) => {
this.utilRegistry.register(util);
});
}
}