export default function potentialEdgeReducer()

in src/state/edge/potentialEdgeReducer.ts [8:31]


export default function potentialEdgeReducer<NodeType, EdgeType>(
  state: DiagramMakerPotentialEdge | null | undefined, action: DiagramMakerAction<NodeType, EdgeType>
): DiagramMakerPotentialEdge | null {
  if (state === undefined) {
    return null;
  }
  switch (action.type) {
    case (EdgeActionsType.EDGE_DRAG_START):
      return {
        position: action.payload.position,
        src: action.payload.id
      };
    case (EdgeActionsType.EDGE_DRAG):
      return produce(state, (draftState) => {
        if (draftState) {
          draftState.position = action.payload.position;
        }
      });
    case (EdgeActionsType.EDGE_DRAG_END):
      return null;
    default:
      return state;
  }
}