aretherecookies-mobile/js/helpers/ImmutableHelpers.js
Bart Akeley 9221b7f9b5 quantities round trip api and stream
make POST requests to /quantity to update the quantity of an existing food item - then mixin the new quantity with the existing food items observable
2017-11-26 19:52:16 -06:00

15 lines
402 B
JavaScript

// @flow
import { type List, type Map } from 'immutable';
export const pushInto = <T>(list: List<T>, item: T): List<T> => list.push(item);
export function merge(a: Map<any, Object>, b: Map<any, Object>) {
return a.merge(b);
}
export const setById = (map: Map<string, any>, item: ?{ id?: string }): Map<string, any> => {
if (!item || !item.id) {
return map;
}
return map.set(item.id, item);
};