1.1.5 • Published 2 years ago
@kkt/plugin-pro-rematch v1.1.5
状态管理
kktp内置插件,是以@rematch/core包为基础进行自动收集状态管理。使用此插件需要安装@rematch/core和@rematch/loading包。
参数
export interface ModelspluginProps {
  /**自动生成文件目录名称*/
  cacheDirName?: string;
}models ts 实例
// src/models/demo.ts
export interface DemoState {
  test?: string;
}
const demo = {
  name: 'demo',
  state: {
    test: '测试State',
  },
  reducers: {
    updateState: (state: DemoState, payload: DemoState): DemoState => ({
      ...state,
      ...payload,
    }),
  },
  effects: (dispatch) => {
    const { demo } = dispatch;
    return {
      async verify() {
        demo.updateState({ test: '测试22' });
      },
    }
  },
};
export default demo;
// src/pages/ceshi.tsx
import { RootState, useSelector, dispatch } from '@kkt/pro';
const Ceshi = () => {
  // 获取demo数据
  const store = useSelector((store: RootState) => store.demo);
  // Dispatch
  const dispatch = useDispatch<Dispatch>();
  const click = () => {
    dispatch({
      type: 'demo/verify',
      payload: {}
    })
  }
  return <div />
}
export default Ceshi;自动收集文件引入
- 约定src/**/models/**/*.(js|ts)文件
kktp配置文件
// .kktprc.ts
export default {
  // ...
  initModel:true,
}Contributors
License
Licensed under the MIT License.
1.1.1
3 years ago
1.1.0
3 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.6-bate.2
3 years ago
1.0.6-bate.1
3 years ago
1.0.1-bate.1
3 years ago
1.0.0-bate.1
3 years ago
1.0.0-alpha.1
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.14
3 years ago
1.0.11-bate.1
3 years ago
1.0.13
3 years ago
1.0.11-bate.2
3 years ago
1.0.12
3 years ago
1.0.0
3 years ago
0.0.12
3 years ago
0.0.11
3 years ago
0.0.10
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.8-alpha.0
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago