Monorepo
of service、state manager for Vue2/Vue3/React. minzipped
less than 300 bytes
。
极其精简的状态管理库,提供了 Vue2/3 和 React 版本。minzipped
不超过 300 bytes
。
name | npm version | bundle size | framework |
---|---|---|---|
vue-hook-svc | vue | ||
react-hook-svc | react |
- 可以区分 全局/业务级
- 全局是单例
- 业务级有生命周期
- 有一个 reactive 的 state ,随便你在哪里用
- 有对应的业务方法,供对应业务组件使用
- 大部分业务应该放在 service 里面声明。
service.method()
- 不需要 props, emit, dispatch。 组件间传值可以是多余的。
- 大部分业务应该放在 service 里面声明。
- 使用简单,不要有太多概念,可以用常规优化方式
- 我不想知道
mutations
,actions
,dispatch
,reducer
,combineXXX
... 时间旅行
等概念很强大,但是99%
的情况用不上,不需要。
- 我不想知道
一个系统,亦或一块业务、一个组件,应该分为 数据
、业务
、UI
3 部分。
常见的 store 往往只是数据层,我希望 状态管理
(service) 可以作为 数据+业务
,组件(UI)只需要展示 service 的数据,调用 service 的方法。