⬅️ Back to Table of Contents
📄 useCounterStore.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
5 |
📦 Imports |
4 |
🟢 Vue Composition API |
1 |
📚 Table of Contents
🛠️ File Location:
📂 packages/shared/createInjectionState/demo/useCounterStore.ts
📦 Imports
Name |
Source |
computed |
vue |
deepRef |
vue |
shallowRef |
vue |
createInjectionState |
../../createInjectionState |
Vue Composition API
Name |
Type |
Reactive Variables |
Composables |
computed |
computed |
none |
none |
Functions
increment(): void
Code
function increment() {
count.value++
}
useCounterStoreWithDefaultValue(): { count: any; double: any; increment: () => void; }
Code
export function useCounterStoreWithDefaultValue() {
return useCounterStore() ?? {
count: shallowRef(0),
double: shallowRef(0),
increment: () => {},
}
}
- Return Type:
{ count: any; double: any; increment: () => void; }
- Calls:
useCounterStore
shallowRef (from vue)
increment(): void
Code
increment(): void
Code
useCounterStoreOrThrow(): { count: any; double: any; increment: () => void; }
Code
export function useCounterStoreOrThrow() {
const counterStore = useCounterStore()
if (counterStore == null)
throw new Error('Please call `useProvideCounterStore` on the appropriate parent component')
return counterStore
}
- Return Type:
{ count: any; double: any; increment: () => void; }
- Calls:
useCounterStore