aretherecookies-mobile/js/streams/FoodItemsStream.js

13 lines
493 B
JavaScript
Raw Normal View History

2017-03-25 21:05:55 -05:00
//@flow
2017-08-05 20:38:29 -05:00
import { createFoodItem } from '../records/FoodItemRecord';
import { setById } from '../helpers/ImmutableHelpers';
import { Map } from 'immutable';
2017-08-27 14:29:37 -05:00
import location$ from './LocationStream';
2017-10-22 12:38:05 -05:00
import { getFoodItemsForLocation, type FoodItemsForLocation } from '../apis/FoodItemsApi';
2017-03-25 21:05:55 -05:00
2017-10-22 12:38:05 -05:00
export default location$
.mergeMap(pos => getFoodItemsForLocation({ pos }))
.map(({ fooditems = [] }: FoodItemsForLocation) => {
return fooditems.map(createFoodItem).reduce(setById, new Map());
});