onlystate
一个仅关注state的状态库,
基于vue3-reactive模块实现,
并且提供vue-devtools插件
特点
- 关注于State,去掉了action,你可以通过compositionAPI来时实现action
使用
npm install onlystate --save-dev
- 定义state
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'
app = createApp(App);
app.use(Astate);
- 基本使用
<script setup>
import {useState} from 'onlystate';
const [a, b] = useState('a', 'b');
a.value = 2;
</script>
TODO