import { BaseObservableValue, ObservableValue } from "../../observable/value"; type AllowsChild = (parent: Segment | undefined, child: Segment) => boolean; /** * OptionalValue is basically stating that if SegmentType[type] = true: * - Allow this type to be optional * - Give it a default value of undefined * - Also allow it to be true * This lets us do: * const s: Segment = new Segment("create-room"); * instead of * const s: Segment = new Segment("create-room", undefined); */ export type OptionalValue = T extends true ? [(undefined | true)?] : [T]; export declare class Navigation { private readonly _allowsChild; private _path; private readonly _observables; private readonly _pathObservable; constructor(allowsChild: AllowsChild); get pathObservable(): ObservableValue>; get path(): Path; push(type: K, ...value: OptionalValue): void; applyPath(path: Path): void; observe(type: keyof T): SegmentObservable; pathFrom(segments: Segment[]): Path; segment(type: K, ...value: OptionalValue): Segment; } export declare class Segment { type: K; value: T[K]; constructor(type: K, ...value: OptionalValue); } declare class Path { private readonly _segments; private readonly _allowsChild; constructor(segments: Segment[] | undefined, allowsChild: AllowsChild); clone(): Path; with(segment: Segment): Path | undefined; until(type: keyof T): Path; get(type: keyof T): Segment | undefined; replace(segment: Segment): Path | undefined; get segments(): Segment[]; } /** * custom observable so it always returns what is in navigation.path, even if we haven't emitted the change yet. * This ensures that observers of a segment can also read the most recent value of other segments. */ declare class SegmentObservable extends BaseObservableValue { private readonly _navigation; private _type; private _lastSetValue?; constructor(navigation: Navigation, type: keyof T); get(): T[keyof T] | undefined; emitIfChanged(): void; } export type { Path }; export declare function tests(): { "applying a path emits an event on the observable": (assert: any) => void; "path.get": (assert: any) => void; "path.replace success": (assert: any) => void; "path.replace not found": (assert: any) => void; };