INNER CODE UNIT · JavaScript
itemKeys
fullstackreact/react-native-firestack · lib/firestackModule.js:96
const itemKeys = state.items.map(i => i._key);
const itemIndex = itemKeys.indexOf(snapshot.key);
let newItems = [].concat(state.items);
newItems.splice(itemIndex, 1);
let list = newItems.sort(this._sortFn)
return this._handleUpdate(T.ITEM_REMOVED, {items: list}, cb);
}
const _itemChanged = (snapshot, prevKey) => {
const state = this._getState()
const existingItem = toObject(snapshot, state);
let list = state.items;
let listIds = state.items.map(i => i._key);
const itemIdx = listIds.indexOf(existingItem._key);
list.splice(itemIdx, 1, existingItem);
return this._handleUpdate(T.ITEM_CHANGED, {items: list}, cb);
}