Skip to content

Instantly share code, notes, and snippets.

@blabadi
Created September 16, 2018 02:34
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 blabadi/f4d0252345c8a8519d2f1a849bd0cf1c to your computer and use it in GitHub Desktop.
Save blabadi/f4d0252345c8a8519d2f1a849bd0cf1c to your computer and use it in GitHub Desktop.
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