Created
June 27, 2019 16:23
-
-
Save kaueDM/84c1c05f1df8d0a6bcb494ec99a4f16d 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
//action | |
export const loginAsync = createAsyncAction( | |
'LOGIN_REQUEST', | |
'LOGIN_SUCCESS', | |
'LOGIN_FAILURE' | |
)<undefined, Auth, string>() | |
//reducer | |
const loginReducer = createReducer(initialState as Auth) | |
.handleAction(loginAsync.request, (state) => { | |
return ({ ...state, loading: true }) | |
}) | |
//rootSaga | |
takeEvery(getType(actions.auth.loginAsync.request), authenticate) | |
// saga (authenticate function) | |
export function* authenticate (action: Action): Generator { | |
yield put(loginAsync.success({ | |
foo: 'Bar' | |
})) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment