兼容 generator 用法

这里是指兼容mutation中的centers的 generator用法。那么需要用到createMutationStoreredux-centergeneratorsToAsync

import { createMutationStore } from 'redux-mutation';
import generatorsToAsync from 'redux-center/lib/generators-to-async';

const mutations = [
  {
    //state: 0,也可以
    initialState: 0,
    namespace: 'counter',
    centers: {
      *increment(action, { put }) {
          yield put({ type: 'loading' });
      },
    },
  },
];
const store = createMutationStore({ generatorsToAsync })(mutations);

Last updated

Was this helpful?