Skip to content

Instantly share code, notes, and snippets.

@ctrlplusb
Created February 8, 2019 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrlplusb/d0b9fcb2cae813d1db5ce5d7c2906b86 to your computer and use it in GitHub Desktop.
Save ctrlplusb/d0b9fcb2cae813d1db5ce5d7c2906b86 to your computer and use it in GitHub Desktop.
import { thunk } from "easy-peasy"; // 👈
const store = createStore<StoreModel>({
todos: {
items: ["Install easy-peasy", "Build app", "profit"],
// 👇renamed
saved: (state, payload) => {
state.items.push(payload);
},
// 👇our thunk
save: thunk(async (actions, payload) => {
await todoService.save(payload);
actions.saved(payload);
})
},
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment