Created
September 16, 2018 02:34
-
-
Save blabadi/f4d0252345c8a8519d2f1a849bd0cf1c 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 foodRepo from '../repos/FoodRepo'; | |
export const SEARCH_FOOD = 'SEARCH_FOOD'; | |
export const RECEIVE_SEARCH_FOOD_RESULTS = 'RECEIVE_SEARCH_FOOD_RESULTS' | |
export const fetchFood = (term) => { | |
return (dispatch) => { | |
dispatch(searchFood); | |
return foodRepo.findFood(term) | |
.then(foods => { | |
dispatch(receiveSearchFoodResults(term, foods)) | |
} | |
); | |
} | |
} | |
export const searchFood = (term) => ({ | |
type: SEARCH_FOOD, | |
term: term | |
}); | |
export const receiveSearchFoodResults = (term, foods) => ({ | |
type: RECEIVE_SEARCH_FOOD_RESULTS, | |
term, | |
results: foods, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment