onlystate
TypeScript icon, indicating that this package has built-in type declarations

0.0.13 • Public • Published

onlystate

一个仅关注state的状态库, 基于vue3-reactive模块实现, 并且提供vue-devtools插件

特点

  • 关注于State,去掉了action,你可以通过compositionAPI来时实现action

使用

npm install onlystate --save-dev

  1. 定义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;
  1. 注册state
import Astate from './store'
//main.js
app = createApp(App);
app.use(Astate);
  1. 基本使用
<script setup>
import {useState} from 'onlystate';
    const [a, b] = useState('a', 'b');
    a.value = 2;
</script>

TODO

  • [x] 基本功能
  • [ ] rollup打包umd、cjs、esm
  • [ ] vue devtools 文件单独打包使用

Package Sidebar

Install

npm i onlystate

Weekly Downloads

2

Version

0.0.13

License

MIT

Unpacked Size

34.7 kB

Total Files

14

Last publish

Collaborators

  • webszy