Give a soul for your app.
$ npm install @zcorky/soul
import soul from '@zcorky/soul';
const app = new Soul();
app.model({
namespace: 'user',
state: {
total: 1,
current: 12138,
list: [{
id: 12138,
name: 'zero',
}],
},
reducers: {
save(state, { payload }) {
const { total, list } = payload;
return {
...state,
total,
list,
};
},
},
effects: {
async 'sync'(action, { put }) {
const { total, user } = await syncUserService();
await put({ type: 'user/save', payload: { total, user } });
},
},
});
app.start();