vue-create-global-state
v1.0.2
Published
Vue 3 global reactive state shared across all components
Maintainers
Readme
Installation
npm install vue-create-global-stateUsage
import { createGlobalState } from 'vue-create-global-state'
import { ref, computed } from 'vue'
export const useGlobalState = createGlobalState(() => {
const count = ref(0)
const doubled = computed(() => count.value * 2)
const increment = () => count.value++
return { count, doubled, increment }
})
const state = useGlobalState()
console.log(state.count.value) // 0
state.increment()
console.log(state.count.value) // 1
console.log(state.doubled.value) // 2License
MIT
Extracted from VueUse for standalone use.
