Skip to content

Commit

Permalink
feat: explicit injection symbols in dev mode (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
cexbrayat committed May 9, 2020
1 parent 6c6c23d commit fab88ee
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/injectionSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ export const hasSymbol =

export const PolySymbol = (name: string) =>
// vr = vue router
hasSymbol ? Symbol(name) : `_vr_` + name
hasSymbol
? Symbol(__DEV__ ? '[vue-router]: ' + name : name)
: (__DEV__ ? '[vue-router]: ' : '_vr_') + name

// rvlm = Router View Location Matched
export const matchedRouteKey = PolySymbol('rvlm') as InjectionKey<
ComputedRef<RouteRecordNormalized | undefined>
>
export const matchedRouteKey = PolySymbol(
__DEV__ ? 'router view location matched' : 'rvlm'
) as InjectionKey<ComputedRef<RouteRecordNormalized | undefined>>
// rvd = Router View Depth
export const viewDepthKey = PolySymbol('rvd') as InjectionKey<number>
export const viewDepthKey = PolySymbol(
__DEV__ ? 'router view depth' : 'rvd'
) as InjectionKey<number>

// r = router
export const routerKey = PolySymbol('r') as InjectionKey<Router>
// rt = route location
export const routeLocationKey = PolySymbol('rl') as InjectionKey<
RouteLocationNormalizedLoaded
export const routerKey = PolySymbol(__DEV__ ? 'router' : 'r') as InjectionKey<
Router
>
// rt = route location
export const routeLocationKey = PolySymbol(
__DEV__ ? 'route location' : 'rl'
) as InjectionKey<RouteLocationNormalizedLoaded>

0 comments on commit fab88ee

Please sign in to comment.