snackbar on food item creation success

This commit is contained in:
Bart Akeley 2018-11-24 10:43:26 -06:00
parent 5000a7049e
commit 9ebc5e4668

View file

@ -4,6 +4,7 @@ import CreateFoodItem$, { emitter as emitCreateItemState } from '../streams/Crea
import { emitter as emitFoodItemsState } from '../streams/FoodItemsStream';
import { createFoodItem } from '../apis/FoodItemsApi';
import FoodItemRecord, { createFoodItem as buildFoodItem } from '../records/FoodItemRecord';
import Snackbar from 'react-native-snackbar';
// should throw an error if not valid
const isFoodItemValid = () => true;
@ -21,6 +22,10 @@ export const withCreateFoodItemState = mapPropsStream(props$ => {
// insert new item into db and cast it into FoodItemRecord
const newItem = buildFoodItem(await createFoodItem(foodItem));
Snackbar.show({
title: foodItem.name + ' added',
});
// notify food items state of new item
emitFoodItemsState(newItem);