rvx
Version:
A signal based rendering library
61 lines (49 loc) • 1.25 kB
text/typescript
import { $, batch } from "../core/signals.js";
import { normalize } from "./path.js";
import { Query, QueryInit } from "./query.js";
import { Router } from "./router.js";
export interface MemoryRouterOptions {
/**
* The initial path.
*/
path?: string;
/**
* The initial query.
*/
query?: QueryInit;
parent?: Router;
}
/**
* A router that keeps it's state in memory instead of the actual browser location.
*/
export class MemoryRouter implements Router {
constructor(options?: MemoryRouterOptions) {
this.
this.
this.
}
get root(): Router {
return this.
}
get parent(): Router | undefined {
return this.
}
get path(): string {
return this.
}
get query(): Query | undefined {
return this.
}
push(path: string, query?: QueryInit): void {
batch(() => {
this.
this.
});
}
replace(path: string, query?: QueryInit): void {
this.push(path, query);
}
}