1
0
Fork 0

Make PageType seporate rom Page.

This commit is contained in:
Kitteh 2021-05-16 09:38:19 +01:00
parent 4e390d3e96
commit 1e95a2af87
2 changed files with 13 additions and 4 deletions

View file

@ -1,9 +1,9 @@
import { Page } from "./Page";
import { PageType } from "./PageType";
import { PageState } from "../PageState";
import { getObjectKeys } from "../utils";
type pageList = {
[key: string]: Page;
[key: string]: PageType;
};
const PageDoesNotExistError = new Error("Page does not exist.");
@ -25,7 +25,7 @@ export class PageRouter extends EventTarget {
private pages: pageList;
private currentPageID: string;
private currentPage: Page;
private currentPage: PageType;
public state: PageState;
public pageContentElement: HTMLElement;
@ -35,7 +35,7 @@ export class PageRouter extends EventTarget {
return getObjectKeys(this.pages);
}
public async getCurrentPage(): Promise<Page> {
public async getCurrentPage(): Promise<PageType> {
return this.currentPage;
}

View file

@ -0,0 +1,9 @@
import { PageRouter } from "./PageRouter";
export type PageType = {
render(): Promise<void>;
getPageTitle(): Promise<Element | string>;
goBack(): Promise<void>;
cleanup(): Promise<void>;
setRouterAndState(router: PageRouter, state: unknown): Promise<void>;
}