I have the following EntityAdapter
export interface IDroneRoute {
assignedDroneId?: number;
routeId: string;
rerouting?: boolean;
waypoints: Waypoint[];
}
export const featureAdapter: EntityAdapter<IDroneRoute> = createEntityAdapter<IDroneRoute>({
selectId: model => model.routeId,
});
I would like to have an action that add, remove and delete a waypoint in the array
const ADD_ROUTE_POINT = (state: State, action: any) => {
return featureAdapter.updateOne({
id: action.payload.routeId,
changes: {// add waypoint},
}, state);
};
how do I access the current array of the item inside the changes so that I can update it ?
changes
corresponds to the entity you want to update (IDroneRoute
), so before youreturn featureAdapter.updateOne({
you can build your updated object.