/// namespace Leaf { interface StackItem { id: string , callback: Function } export class History { handlePopState() { } constructor() { this.handlePopState = this.handlePopState.bind(this) } private stack: StackItem[] = [] push(id: string, callback: Function) { this.stack.push({ id, callback }) } remove(id: string) { this.stack = this.stack.filter(item => item.id != id) } activate() { window.addEventListener("popstate", this.handlePopState) } deactivate() { window.removeEventListener("popstate", this.handlePopState) } } }