@roxi/routify
Version:
17 lines (15 loc) • 503 B
JavaScript
import { BaseReflector } from './ReflectorBase.js'
export class LocalStorageReflector extends BaseReflector {
/** @param {Router} router */
constructor(router) {
super(router)
this.storageName = `__routify-router-${this.router.name}`
}
reflect() {
window.localStorage.setItem(this.storageName, this.router.url.internal())
}
install() {
const url = window.localStorage.getItem(this.storageName)
this.router.url.replace(url || '/')
}
}