Created
October 12, 2017 16:10
-
-
Save JamesTheHacker/280b75dde808351831798e770c06e797 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
// This is a reducer, same as Redux's | |
const reducer = (state, action) => { | |
switch(action.type) { | |
case 'FETCHING_TWEETS': | |
return {...state, fetchingTweets: true}; | |
break; | |
case 'TWEETS_RECEIVED': | |
return { ...state, | |
fetchingTweets: false, | |
tweets: action.tweets | |
}; | |
default: | |
return state; | |
} | |
} | |
// Default state | |
const initialState = { | |
fetchingTweets: false, | |
tweets: [] | |
}; | |
// Create state store | |
const store = new FauxRedux(reducer, initialState); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment