Skip to content

Commit

Permalink
feat(element): separate _initLocale, _initRouter and _routeChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Jan 18, 2023
1 parent d6343f6 commit a0af8ec
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ui/element/src/pwa-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,26 @@ export class AlwatrPwaElement extends AlwatrSmartElement {

constructor() {
super();
this._initLocale();
this._initRouter();
}

protected _initRouter(): void {
l10n.config.defaultLocale = {
code: 'en-US',
direction: 'ltr',
language: 'en',
};
protected _initLocale(): void {
this._logger.logMethod('_initLocale');
l10n.setLocal();
}

router.signal.addListener((route) => {
this._logger.logMethodArgs('routeChanged', {route});
this.requestUpdate();
});

protected _initRouter(): void {
this._logger.logMethod('_initRouter');
router.signal.addListener(this._routeChanged.bind(this));
router.initial();
}

protected _routeChanged(): void {
this._logger.logMethod('routeChanged');
this.requestUpdate();
}

override render(): unknown {
super.render();
return html`<div class="page-container">${cache(router.outlet(this._routes))}</div>`;
Expand Down

0 comments on commit a0af8ec

Please sign in to comment.