Skip to content

Instantly share code, notes, and snippets.

@kaueDM
Created June 27, 2019 16:23
Show Gist options
  • Save kaueDM/84c1c05f1df8d0a6bcb494ec99a4f16d to your computer and use it in GitHub Desktop.
Save kaueDM/84c1c05f1df8d0a6bcb494ec99a4f16d to your computer and use it in GitHub Desktop.
//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