Skip to content

Instantly share code, notes, and snippets.

@LukeSmetham
Last active September 24, 2019 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LukeSmetham/bab23d7d47e2aceb37483e5f30cf4a40 to your computer and use it in GitHub Desktop.
Save LukeSmetham/bab23d7d47e2aceb37483e5f30cf4a40 to your computer and use it in GitHub Desktop.
import { LOGIN } from './types';
const init = {
user: JSON.parse(localStorage.getItem('user')),
streamToken: localStorage.getItem('streamToken'),
loading: false,
error: false,
};
export default (state = init, action) => {
switch (action.type) {
case LOGIN.REQUEST:
return {
...state,
loading: true,
};
case LOGIN.SUCCESS:
return {
...state,
loading: false,
user: action.user,
streamToken: action.token,
};
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment