Skip to content

⬅️ Back to Table of Contents

📄 useCounterStore

📊 Analysis Summary

Metric Count
🔧 Functions 4
📦 Imports 3
🟢 Vue Composition API 1

📚 Table of Contents

🛠️ File Location:

📂 packages/shared/createInjectionState/demo/useCounterStore.ts

📦 Imports

Name Source
computed vue
shallowRef vue
createInjectionState ../../createInjectionState

Vue Composition API

Name Type Reactive Variables Composables
computed computed none none

Functions

useCounterStoreWithDefaultValue(): { count: any; double: any; increment: () => void; }

Returns: { count: any; double: any; increment: () => void; }

Calls:

  • useCounterStore
  • shallowRef (from vue)
Code
export function useCounterStoreWithDefaultValue() {
  return useCounterStore() ?? {
    count: shallowRef(0),
    double: shallowRef(0),
    increment: () => {},
  }
}

useCounterStoreOrThrow(): { count: any; double: any; increment: () => void; }

Returns: { count: any; double: any; increment: () => void; }

Calls:

  • useCounterStore
Code
export function useCounterStoreOrThrow() {
  const counterStore = useCounterStore()
  if (counterStore == null)
    throw new Error('Please call `useProvideCounterStore` on the appropriate parent component')
  return counterStore
}

Internal helpers

Declared inside another function in this file.

increment(): void

Returns: void

Code
function increment() {
    count.value++
  }

useCounterStoreWithDefaultValue.increment(): void

Returns: void

Code
() => {}

Generated by Syntax Scribe