fixed architecture to dispatch events when routes and token changes

This commit is contained in:
Fran Jurmanović
2021-05-31 12:00:07 +02:00
parent 48df6fc7cf
commit e1ab0e51d6
10 changed files with 131 additions and 29 deletions

View File

@@ -21,13 +21,15 @@ class AppLinkElement extends HTMLElement {
this.routerService = this.appMain?.routerService;
this.update();
if (isTrue(this.goBack)) {
window.addEventListener("routechanged", () => {
this.update();
});
window.addEventListener("routechanged", this.update);
}
}
public disconnectedCallback(): void {}
public disconnectedCallback(): void {
if (isTrue(this.goBack)) {
window.removeEventListener("routechanged", this.update);
}
}
goTo = () => {
if (!isTrue(this.goBack) && this.to) {
@@ -55,7 +57,7 @@ class AppLinkElement extends HTMLElement {
>`}`;
}
update() {
update = () => {
render(this.render(), this);
}
};
}