mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 06:14:55 -06:00
debounce getFoodItems
This commit is contained in:
parent
d00a4f6ad3
commit
2d3a706333
1 changed files with 4 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import FoodItemRecord from '../records/FoodItemRecord';
|
||||||
import AuthManager from '../AuthManager';
|
import AuthManager from '../AuthManager';
|
||||||
import { addImage } from './ImagesApi';
|
import { addImage } from './ImagesApi';
|
||||||
import { fetchRequest } from './FetchApi';
|
import { fetchRequest } from './FetchApi';
|
||||||
|
import debounce from '../helpers/debounce';
|
||||||
|
|
||||||
export type FoodItemsFilter = {
|
export type FoodItemsFilter = {
|
||||||
radius?: number,
|
radius?: number,
|
||||||
|
|
@ -28,8 +29,7 @@ export type FoodItemsForLocation = {
|
||||||
fooditems: ?Array<RawFoodItem>,
|
fooditems: ?Array<RawFoodItem>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFoodItems = memoizeWith(
|
export const getFoodItems = debounce(
|
||||||
({ loc, filter }) => `${loc.coords.latitude + loc.coords.longitude}:${filter.toString()}`,
|
|
||||||
async ({
|
async ({
|
||||||
loc,
|
loc,
|
||||||
filter,
|
filter,
|
||||||
|
|
@ -71,7 +71,8 @@ export const getFoodItems = memoizeWith(
|
||||||
error: error,
|
error: error,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
300
|
||||||
);
|
);
|
||||||
|
|
||||||
export const createFoodItem = async (foodItem: FoodItemRecord) => {
|
export const createFoodItem = async (foodItem: FoodItemRecord) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue