Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Last active December 8, 2017 12:11
Show Gist options
  • Save vzaidman/9d3b582f891e8118195daa5b07d9596c to your computer and use it in GitHub Desktop.
Save vzaidman/9d3b582f891e8118195daa5b07d9596c to your computer and use it in GitHub Desktop.
import { makeThunkActionCreator } from 'redux-toolbelt-thunk'
import { api } from '../services'
export const login = makeThunkActionCreator(‘login’,(email, password) => api.login(email, password)))
export const signUp = makeThunkActionCreator(‘signUp’, signUpData => api.signUp(signUpData))
export const fetchProfile = makeThunkActionCreator(‘fetchProfile’, () => api.fetchProfile())
export const logout = makeThunkActionCreator(‘logout’, () => api.logout().then(() => {return undefined})
import { composeReducers, makeAsyncReducer } from 'redux-toolbelt'
import { login, logout, signUp, fetchProfile } from './actions'
export const profile = composeReducers(
makeAsyncReducer(login),
makeAsyncReducer(signUp),
makeAsyncReducer(fetchProfile, { shouldDestroyData: false }),
makeAsyncReducer(logout),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment