β¬ οΈ Back to Table of Contents
π useNProgress¶
π Analysis Summary¶
| Metric | Count |
|---|---|
| π§ Functions | 2 |
| π¦ Imports | 11 |
| π’ Vue Composition API | 1 |
| π Interfaces | 1 |
| π Type Aliases | 1 |
π Table of Contents¶
π οΈ File Location:¶
π packages/integrations/useNProgress/index.ts
π¦ Imports¶
| Name | Source |
|---|---|
NProgress |
nprogress |
NProgressOptions |
nprogress |
MaybeRefOrGetter |
vue |
Ref |
vue |
WritableComputedRef |
vue |
isClient |
@vueuse/shared |
toRef |
@vueuse/shared |
tryOnScopeDispose |
@vueuse/shared |
nprogress |
nprogress |
computed |
vue |
watchEffect |
vue |
Vue Composition API¶
| Name | Type | Reactive Variables | Composables |
|---|---|---|---|
computed |
computed | none | none |
Functions¶
useNProgress(currentProgress: MaybeRefOrGetter<number | null | undefiβ¦, options: UseNProgressOptions): UseNProgressReturn¶
Reactive progress bar.
See: https://vueuse.org/useNProgress
Calls:
toRef (from @vueuse/shared)computed (from vue)nprogress.startnprogress.donenprogress.configuresetProgress.callwatchEffect (from vue)tryOnScopeDispose (from @vueuse/shared)nprogress.remove
Code
export function useNProgress(
currentProgress: MaybeRefOrGetter<number | null | undefined> = null,
options?: UseNProgressOptions,
): UseNProgressReturn {
const progress = toRef(currentProgress)
const isLoading = computed({
set: load => load ? nprogress.start() : nprogress.done(),
get: () => typeof progress.value === 'number' && progress.value < 1,
})
if (options)
nprogress.configure(options)
const setProgress = nprogress.set
nprogress.set = (n: number) => {
progress.value = n
return setProgress.call(nprogress, n)
}
watchEffect(() => {
if (typeof progress.value === 'number' && isClient)
setProgress.call(nprogress, progress.value)
})
tryOnScopeDispose(nprogress.remove)
return {
isLoading,
progress,
start: nprogress.start,
done: nprogress.done,
remove: () => {
progress.value = null
nprogress.remove()
},
}
}
Internal helpers¶
Declared inside another function in this file.
remove(): void¶
Returns: void
Calls:
nprogress.remove
Interfaces¶
UseNProgressReturn¶
Interface Code
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
isLoading |
WritableComputedRef<boolean, boolean> |
β | not shown |
progress |
Ref<number \| null \| undefined> |
β | not shown |
start |
() => NProgress |
β | not shown |
done |
(force?: boolean) => NProgress |
β | not shown |
remove |
() => void |
β | not shown |
Type Aliases¶
UseNProgressOptions¶
Generated by Syntax Scribe