Created
November 5, 2018 20:10
-
-
Save ctrlplusb/b61b4caa870531a5ed85bc0f05384407 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore, effect } from 'easy-peasy'; // 👈 import the helper | |
const store = createStore({ | |
session: { | |
user: undefined, | |
// 👇 define your effectful action | |
login: effect(async (dispatch, payload, getState) => { | |
const user = await loginService(payload) | |
dispatch.session.loginSucceeded(user) | |
}), | |
loginSucceeded: (state, payload) => { | |
state.user = payload | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment