Fastkit

vue-location

Custom classes for Type-safe handling of exceptions in your application.

Installation

npm install @fastkit/vue-location

LocationService
class

Location Service

A class for referencing and manipulating the state of vue-router.

# Signature
(ctx: LocationServiceContext): LocationService
# Parameters
NameTypeDefault
ctx*LocationServiceContext
# Return Type
LocationService

state
readonly

LocationServiceState

The state of the location service

router
readonly

Router

Router instance.

currentRoute
function

# Signature
(): RouteLocationNormalizedLoaded

The currently active route

# Parameters
NameTypeDefault
# Return Type
RouteLocationNormalizedLoaded

The currently active route

watchRoute
function

# Signature
<Immediate extends Readonly<boolean> = false>(cb: WatchCallback<RouteLocationNormalizedLoaded, Immediate extends true ? RouteLocationNormalizedLoaded | undefined : RouteLocationNormalizedLoaded>, options?: WatchRouteOptions<Immediate>): WatchStopHandle

Watching route transitions

# Parameters
NameTypeDefault
cb*WatchCallback<RouteLocationNormalizedLoaded, Immediate extends true ? RouteLocationNormalizedLoaded | undefined : RouteLocationNormalizedLoaded>
Callback function
optionsWatchRouteOptions<Immediate> | undefined
Watch options
# Return Type
WatchStopHandle

Stop function for the watcher

transitioningTo
function

# Signature
(): _RouteLocationBase | null

The route location object that will be the destination when the route is in the process of transitioning

# Parameters
NameTypeDefault
# Return Type
null | _RouteLocationBase

The route location object that will be the destination when the route is in the process of transitioning

transitioning
function

# Signature
(): LocationTransitioning | null

The state of route transition

# Parameters
NameTypeDefault
# Return Type
null | LocationTransitioning

The state of route transition

locationIsMatched
function

# Signature
(target: RouteLocationRaw): boolean

Checks whether the specified location matches the current route.

# Parameters
NameTypeDefault
target*RouteLocationRaw
The location to be checked for a match with the current route.
# Return Type
boolean

Returns true if the specified location matches the current route, otherwise returns false.

isQueryOnlyTransitioning
function

# Signature
(queries?: string | string[]): boolean

Check if the specified query is in the process of transitioning

# Parameters
NameTypeDefault
queriesstring | string[] | undefined
The query name or a list of queries to check
# Return Type
boolean

Returns true if it is in the process of transitioning

match
function

# Signature
(raw?: RouteLocationRaw, opts?: SameRouteCheckOptions): boolean

Check if the specified route matches the current route

# Parameters
NameTypeDefault
rawRouteLocationRaw | undefined
The route object to check
optsSameRouteCheckOptions | undefined
# Return Type
boolean

Returns true if it matches

getMatchedComponents
function

# Signature(1 / 2)
(): RawRouteComponent[]

Retrieve an array of components that match the currently active route

# Parameters
NameTypeDefault
# Return Type
RawRouteComponent[]

An array of matching components

# Signature(2 / 2)
(raw: RouteLocationRaw): RawRouteComponent[]

Get an array of components that match the specified route

# Parameters
NameTypeDefault
raw*RouteLocationRaw
The route object from which to extract components
# Return Type
RawRouteComponent[]

An array of matching components

isAvailable
function

# Signature(1 / 2)
(): boolean

Check if the current route is a valid route

This checks if there are one or more matching components.

# Parameters
NameTypeDefault
# Return Type
boolean

Check if the current route is a valid route

This checks if there are one or more matching components.

# Signature(2 / 2)
(raw?: RouteLocationRaw): boolean

Check if the specified route object is a valid route

# Parameters
NameTypeDefault
rawRouteLocationRaw | undefined
The route object to check This checks if there are one or more matching components.
# Return Type
boolean

Check if the specified route object is a valid route

useQuery
function

# Signature
<Schema extends QueriesSchema<import("/home/runner/work/fastkit/fastkit/packages/vue-location/src/composables/query/_internal").Data>>(schema: Schema): TypedQuery<Schema>

Generate an interface for extracting and utility functions for query values corresponding to the specified schema:

# Parameters
NameTypeDefault
schema*Schema
Queries schema
# Return Type
TypedQuery<Schema>

An interface for extracting query values corresponding to a schema and utility functions

getQuery
function

# Signature(1 / 8)
(key: string): string | undefined
# Parameters
NameTypeDefault
key*string
# Return Type
undefined | string
# Signature(2 / 8)
(key: string, type: undefined, defaultValue: string): string
# Parameters
NameTypeDefault
key*string
type*undefined
defaultValue*string
# Return Type
string
# Signature(3 / 8)
(key: string, type: StringConstructor): string | undefined
# Parameters
NameTypeDefault
key*string
type*StringConstructor
# Return Type
undefined | string
# Signature(4 / 8)
(key: string, type: StringConstructor, defaultValue: string): string
# Parameters
NameTypeDefault
key*string
type*StringConstructor
defaultValue*string
# Return Type
string
# Signature(5 / 8)
(key: string, type: NumberConstructor): number | undefined
# Parameters
NameTypeDefault
key*string
type*NumberConstructor
# Return Type
undefined | number
# Signature(6 / 8)
(key: string, type: NumberConstructor, defaultValue: number): number
# Parameters
NameTypeDefault
key*string
type*NumberConstructor
defaultValue*number
# Return Type
number
# Signature(7 / 8)
(key: string, type: BooleanConstructor): boolean
# Parameters
NameTypeDefault
key*string
type*BooleanConstructor
# Return Type
boolean
# Signature(8 / 8)
(key: string, type: BooleanConstructor, defaultValue: boolean): boolean
# Parameters
NameTypeDefault
key*string
type*BooleanConstructor
defaultValue*boolean
# Return Type
boolean

getQueryMergedLocation
function

# Signature
(query: LocationQueryRaw, route?: RouteLocationNormalizedLoaded): _RouteLocationBase
# Parameters
NameTypeDefault
query*LocationQueryRaw
routeRouteLocationNormalizedLoadedthis.currentRoute
# Return Type
_RouteLocationBase

push
function

# Signature
(to: RouteLocationRaw): Promise<void | import("/home/runner/work/fastkit/fastkit/node_modules/.pnpm/vue-router@4.2.4_vue@3.3.4/node_modules/vue-router/dist/vue-router").NavigationFailure | undefined>
# Parameters
NameTypeDefault
args[to: RouteLocationRaw]
# Return Type
Promise<void | NavigationFailure | undefined>

pushQuery
function

# Signature
(query: LocationQueryRaw): Promise<void | import("/home/runner/work/fastkit/fastkit/node_modules/.pnpm/vue-router@4.2.4_vue@3.3.4/node_modules/vue-router/dist/vue-router").NavigationFailure | undefined>
# Parameters
NameTypeDefault
query*LocationQueryRaw
# Return Type
Promise<void | NavigationFailure | undefined>

replace
function

# Signature
(to: RouteLocationRaw): Promise<void | import("/home/runner/work/fastkit/fastkit/node_modules/.pnpm/vue-router@4.2.4_vue@3.3.4/node_modules/vue-router/dist/vue-router").NavigationFailure | undefined>
# Parameters
NameTypeDefault
args[to: RouteLocationRaw]
# Return Type
Promise<void | NavigationFailure | undefined>

replaceQuery
function

# Signature
(query: LocationQueryRaw): Promise<void | import("/home/runner/work/fastkit/fastkit/node_modules/.pnpm/vue-router@4.2.4_vue@3.3.4/node_modules/vue-router/dist/vue-router").NavigationFailure | undefined>
# Parameters
NameTypeDefault
query*LocationQueryRaw
# Return Type
Promise<void | NavigationFailure | undefined>

go
function

# Signature
(delta: number): void
# Parameters
NameTypeDefault
args[delta: number]
# Return Type
void

back
function

# Signature
(): void
# Parameters
NameTypeDefault
args[]
# Return Type
void

forward
function

# Signature
(): void
# Parameters
NameTypeDefault
args[]
# Return Type
void