SomethingSexy / platform-builder

0 stars 0 forks source link

Better way to handle array data #32

Open SomethingSexy opened 8 years ago

SomethingSexy commented 8 years ago
export function applications(state = [], action) {
  switch (action.type) {
    case CREATING_APPLICATION:
      // loop through each applications
      return state.map(application => {
        if (application.id !== action.id) {
          return application;
        }

        return {
          ...application,
          saving: true
        };
      });
    case CREATED_APPLICATION:
      // loop through each applications
      return state.map(application => {
        if (application.id !== action.id) {
          return application;
        }

        return {
          ...application,
          saving: false
        };
      });
    default:
      return state;
  }
}