added getters from main app element to other elements

This commit is contained in:
Fran Jurmanović
2021-06-03 19:18:50 +02:00
parent 7e3332e32c
commit b36e7f0ca6
6 changed files with 38 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
import { html, render, TemplateResult } from "@github/jtml";
import { AppMainElement } from "components/";
import { AppMainElement, AppModalElement, AppRootElement } from "components/";
import { AppService, RouterService } from "core/services";
import { AuthStore } from "core/store";
import { closest } from "core/utils";
class BaseElement extends HTMLElement {
@@ -12,7 +14,31 @@ class BaseElement extends HTMLElement {
this.disconnectedCallback = this.disconnectedCallback.bind(this);
}
bindEvents = (): void => {
public get routerService(): RouterService {
return this.appMain?.routerService;
}
public get authStore(): AuthStore {
return this.appMain?.authStore;
}
public get appService(): AppService {
return this.appMain?.appService;
}
public get appModal(): AppModalElement {
return this.appMain?.appModal;
}
public get mainRoot(): AppRootElement {
return this.appMain?.mainRoot;
}
public get isAuth(): boolean {
return this.appMain?.isAuth();
}
public bindEvents = (): void => {
const _elems = this.querySelectorAll("[data-action]");
_elems?.forEach((el) => {
for (const action of (el.getAttribute("data-action") || "")