UNPKG

react-native-template-zygor

Version:

Template para projetos em React Native, com Estrutura de Pastas customizada, Estilos Globais, ESLint + Prettier + Babel Plugin Root Import, React Navigation, Reactotron e Axios configurados.

24 lines (19 loc) 633 B
import { call, put } from 'redux-saga/effects'; import Api from '~/services/Api'; import jwtService from '../jwtService'; import { AuthActions } from './auth-duck'; export function* loadAuth({ email, password }) { try { const response = yield call(jwtService.login, email, password); yield put(AuthActions.loadAuthSuccess(response)); } catch (e) { yield put(AuthActions.loadAuthFailure('Invalid user, try again')); } } export function* logout() { yield call(jwtService.logout); } export function* updateUser() { const response = yield call(Api.fetchUser); yield put(AuthActions.setUser(response.data)); }