forked from mystiq/hydrogen-web
Give defaultt type
This commit is contained in:
parent
f49d580d49
commit
9300347e9b
2 changed files with 4 additions and 3 deletions
|
@ -27,6 +27,7 @@ import type {Platform} from "../platform/web/Platform";
|
||||||
import type {Clock} from "../platform/web/dom/Clock";
|
import type {Clock} from "../platform/web/dom/Clock";
|
||||||
import type {ILogger} from "../logging/types";
|
import type {ILogger} from "../logging/types";
|
||||||
import type {Navigation} from "./navigation/Navigation";
|
import type {Navigation} from "./navigation/Navigation";
|
||||||
|
import type {SegmentType} from "./navigation/index";
|
||||||
import type {URLRouter} from "./navigation/URLRouter";
|
import type {URLRouter} from "./navigation/URLRouter";
|
||||||
|
|
||||||
type Options<N extends {session: string}> = {
|
type Options<N extends {session: string}> = {
|
||||||
|
@ -37,7 +38,7 @@ type Options<N extends {session: string}> = {
|
||||||
emitChange?: (params: any) => void
|
emitChange?: (params: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewModel<N extends {session: string}, O extends Options<N> = Options<N>> extends EventEmitter<{change: never}> {
|
export class ViewModel<N extends {session: string} = SegmentType, O extends Options<N> = Options<N>> extends EventEmitter<{change: never}> {
|
||||||
private disposables?: Disposables;
|
private disposables?: Disposables;
|
||||||
private _isDisposed = false;
|
private _isDisposed = false;
|
||||||
private _options: Readonly<O>;
|
private _options: Readonly<O>;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import {Navigation, Segment} from "./Navigation";
|
||||||
import {URLRouter} from "./URLRouter";
|
import {URLRouter} from "./URLRouter";
|
||||||
import type {Path, OptionalValue} from "./Navigation";
|
import type {Path, OptionalValue} from "./Navigation";
|
||||||
|
|
||||||
type SegmentType = {
|
export type SegmentType = {
|
||||||
"login": true;
|
"login": true;
|
||||||
"session": string;
|
"session": string;
|
||||||
"sso": string;
|
"sso": string;
|
||||||
|
@ -124,7 +124,7 @@ export function addPanelIfNeeded<T extends SegmentType>(navigation: Navigation<T
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseUrlPath(urlPath: string, currentNavPath: Path<SegmentType>, defaultSessionId?: string): Segment<SegmentType>[] {
|
export function parseUrlPath(urlPath: string, currentNavPath: Path<SegmentType>, defaultSessionId?: string): Segment<SegmentType>[] {
|
||||||
// substr(1) to take of initial /
|
// substring(1) to take of initial /
|
||||||
const parts = urlPath.substring(1).split("/");
|
const parts = urlPath.substring(1).split("/");
|
||||||
const iterator = parts[Symbol.iterator]();
|
const iterator = parts[Symbol.iterator]();
|
||||||
const segments: Segment<SegmentType>[] = [];
|
const segments: Segment<SegmentType>[] = [];
|
||||||
|
|
Loading…
Reference in a new issue