Skip to content

Instantly share code, notes, and snippets.

@nightspirit
Last active February 16, 2019 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nightspirit/cc2a2149058cd71948bf54fd270b4c01 to your computer and use it in GitHub Desktop.
Save nightspirit/cc2a2149058cd71948bf54fd270b4c01 to your computer and use it in GitHub Desktop.
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