@micro-router
    Preparing search index...

    Type Alias Router<Result, KnownResult, Exhaustive>

    type Router<
        Result = never,
        KnownResult extends boolean = false,
        Exhaustive extends boolean = false,
    > = {
        default<DefaultHandler extends (() => Result) | (() => any)>(
            f: DefaultHandler,
        ): Router<
            KnownResult extends true ? Result : Result | ReturnType<DefaultHandler>,
            KnownResult,
            true,
        >;
        dispatch(
            input: string,
            opts?: DispatchOpts,
        ): Exhaustive extends true ? Result : Result | null;
        exhaustive(): Router<Result, KnownResult, true>;
        on<
            P extends Path<string, any>,
            Handler extends RouteHandler<P, Result> | RouteHandler<P, any>,
        >(
            path: P,
            handler: Handler,
        ): Router<
            KnownResult extends true ? Result : Result | ReturnType<Handler>,
            KnownResult,
            Exhaustive,
        >;
    }

    Type Parameters

    • Result = never
    • KnownResult extends boolean = false
    • Exhaustive extends boolean = false
    Index

    Methods

    • Matches all of this router's registered paths against the provided input string.

      If at least one registered path matches the input string, this method will determine the one registered path that best matches the input, using the strategy determined by the provided comparator.

      Only the handler for the best matching path will be called. Its return value, if any, will be returned from this method.

      If no paths match, but a default handler has been supplied, that handler will be called and its return value will be returned.

      If no paths match, but .exhaustive() has been called, then this method will throw an exception.

      Otherwise, null will be returned.

      Parameters

      • input: string

        The input string to match against registered paths

      • Optionalopts: DispatchOpts

        Optional dispatch configuration to override router-level settings

      Returns Exhaustive extends true ? Result : Result | null

    • Calling this method will cause the router to throw an Error when none of its registered paths match the input being dispatched.

      Returns Router<Result, KnownResult, true>