Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { createReducer } from 'Reducers/helpers'
import merge from 'lodash-es/merge'
const initState = {
accessToken: null,
refreshToken: null
}
// handlers
function set (state, { accessToken, refreshToken }) {
return merge({}, state, { accessToken, refreshToken })
}
function reset (state) {
return {
...initState
}
}
const reducer = createReducer({
'TOKEN:SET': set,
'TOKEN:RESET': reset
}, initState)
export default reducer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment