updateNullableItem<T> function

ThunkAction<SwipeFeedState<T>> updateNullableItem<T>(
  1. T newItem, {
  2. Function? beforeUpdate,
})

Implementation

ThunkAction<SwipeFeedState<T>> updateNullableItem<T>(T newItem, {Function? beforeUpdate}){
  return (Store<SwipeFeedState<T>> store) async {
    List<Tuple2<T?, Store<SwipeFeedCardState>>> items = store.state.items;
    if(items.isNotEmpty){
      Tuple2<T?, Store<SwipeFeedCardState>> item = items[0];
      items.remove(items[0]);
      store.dispatch(SetItemsEvent(items));
      items = [Tuple2(newItem, item.item2), ...items];
      store.dispatch(SetItemsEvent(items));
    }
  };
}