Q:

Connect two actions to one reducer?

Can I connect two actions to one reducer?
What I want to do is fetch an object (that will have the same property types)
From two different actions and then add it into the state, I want it to be like this:
If I call action1 the state should be the result of action1, if I then call action2 the result of action1 in the state should be overwritten by the result of action2. Therefor I want to use two actions connected to one reducer. So they use the same property in the store  (state).
First Action
export function projectHasErrored(bool){
    return {
        type: 'PROJECT_HAS_ERRORED',
        hasErrored: bool
    };
}

export function projectIsLoading(bool){
    return {
        type: 'PROJECT_IS_LOADING',
        isLoading: bool
    };
}

export function projectFetchDataSuccess(project){
    console.log(project)
    return {
        type: 'PROJECT_FETCH_SUCCESS',
        project
    };
}

export function projectFetchData(url, {owner, projectName}){
    console.log(projectName + "! hejhej")
    return (dispatch) => {
        dispatch(projectIsLoading(true));

        fetch(url,{
            method: 'POST',
            data: {
                owner,
                projectName
            }
            })
            .then((response) => {
                if(!response.ok){
                    throw Error(response.statusText)
                }

                dispatch(projectIsLoading(false));

                return response;
            })
            .then((response) => response.json())
            .then((project) => dispatch(projectFetchDataSuccess(project)))
            .catch(() => dispatch(projectHasErrored(true)));
    };
}

2nd action
export function lastProjectHasErrored(bool){
    return {
        type: 'PROJECT_HAS_ERRORED',
        hasErrored: bool
    };
}

export function lastProjectIsLoading(bool){
    return {
        type: 'PROJECT_IS_LOADING',
        isLoading: bool
    };
}

export function projectFetchDataSuccess(project){
    console.log(project)
    return {
        type: 'PROJECT_FETCH_SUCCESS',
        project
    };
}

export function lastProjectFetchData(url, owner){
    return (dispatch) => {
        dispatch(lastProjectIsLoading(true));
        fetch(url,{
            method: 'POST',
            data: {
                owner
            }
            })
            .then((response) => {
                if(!response.ok){
                    throw Error(response.statusText)
                }

                dispatch(lastProjectIsLoading(false));

                return response;
            })
            .then((response) => response.json())
            .then((project) => dispatch(lastProjectFetchDataSuccess(project)))
            .catch(() => dispatch(lastProjectHasErrored(true)));
    };
}

The Reducer
export function projectHasErrored(state = false, action){
    switch(action.type){
      case 'PROJECT_HAS_ERRORED':
        return action.hasErrored;

      default:
        return state
    }
}

export function projectIsLoading(state = false, action){
  switch(action.type){
    case 'PROJECT_IS_LOADING':
      return action.isLoading;

    default:
      return state
  }
}

export function project(state = [], action){
  switch(action.type){
    case 'PROJECT_FETCH_SUCCESS':
      return action.project;

    default:
      return state
  }
}

A:

you can connect one or more actions to a reducer.
//action1.js
 `export function Add(data){
      return (dispatch)=>{
          dispatch(type:'SET_DATA',data})   
      } 
  }`

//action2.js
`export function Sub(value){
     return (dispatch)=>{
         dispatch({type:'SET_VALUE',value})
     }
 }

Now in your reducer.js
const initialState={
  data:''
  value:''
}
export default function initialReducer(state=initialState,action){
    switch(action.type){
        case 'SET_DATA':{
         return {
              ...state,
              data:action.data
         }
         }
         case 'SET_VALUE':{
         return {
              ...state,
              data:action.value
         }
         }
         default: {return state}
    }
}

Therefore , the actions would be connected to the same reducer.

