onlystate
v0.0.13
Published
A state and only state management library for Vue3
Downloads
6
Maintainers
Readme
onlystate
一个仅关注state的状态库, 基于vue3-reactive模块实现, 并且提供vue-devtools插件
特点
- 关注于State,去掉了action,你可以通过compositionAPI来时实现action
使用
npm install onlystate --save-dev
- 定义state
//store.js
import {defineState} from 'onlystate';
const install = defineState({
a: 1,
b: 2
}, {
c: state => 'a=' + state.a,
d: state => 'b=' + state.b
});
export default install;
- 注册state
import Astate from './store'
//main.js
app = createApp(App);
app.use(Astate);
- 基本使用
<script setup>
import {useState} from 'onlystate';
const [a, b] = useState('a', 'b');
a.value = 2;
</script>
TODO
- [x] 基本功能
- [ ] rollup打包umd、cjs、esm
- [ ] vue devtools 文件单独打包使用