0.4.0 • Published 3 years ago
@nnwa/redux-saga-actions v0.4.0
@nnwa/redux-saga-actions
帮助 react 应用更容易使用数据流
使用
$ yarn add @nnwa/redux-saga-actions
// store.js
import {
createSaga,
GenStateType,
genUseReduxState,
getState,
} from '@nnwa/redux-saga-actions';
import genStore from '@nnwa/redux-saga-actions/store';
import * as models from './models';
export const store = genStore(models);
const state = getState(models);
export type IState = typeof state;
export const useReduxState = genUseReduxState<IState>();
接口使用
createActions
const model = {
namespace: 'user',
state: {},
reducers: {},
effects: {
fetchUser() {},
},
};
const actions = createActions(model);
actions.fetchUser(); // { type: 'user/fetchUser' }