Vue
Install
npm install overmind overmind-vueHooks (experimental)
// overmind/index.js
import {
createStateHook,
createActionsHook,
createEffectsHook,
createReactionHook
} from 'overmind-vue/vue3'
export const config = {
state: {
foo: 'bar'
},
actions: {
onClick() {}
},
effects: {}
}
export const hooks = {
state: createStateHook(),
actions: createActionsHook(),
effects: createEffectsHook(),
reaction: createReactionHook()
}
// index.js
import { createOvermind } from 'overmind'
import { withOvermind } from 'overmind-vue/vue3'
import { config } from './overmind'
import App from './App.vue'
const overmind = createOvermind(config)
createApp(withOvermind(overmind, App)).mount('#app')
...
// components/SomeComponent.vue
<template>
<div @click="actions.onClick">
{{ state.foo }}
</div>
</template>
<script>
import { hooks } from '../overmind'
export default {
setup() {
const state = hooks.state()
const actions = hooks.actions()
return { state, actions }
}
}
</script>Accessing state in setup
Scoped tracking
Plugin
Rendering
Pass state as props
Reactions
Connect
Computed
Using props
Last updated