Last active
February 16, 2019 08:41
-
-
Save nightspirit/cc2a2149058cd71948bf54fd270b4c01 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
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