[251106] fix: Dispatch Queue implementation
🕐 커밋 시간: 2025. 11. 06. 20:46:35 📊 변경 통계: • 총 파일: 7개 • 추가: +398줄 • 삭제: -1줄 📁 추가된 파일: + com.twin.app.shoptime/src/utils/advancedAsyncPanelExamples.js + com.twin.app.shoptime/src/utils/asyncActionUtils.js + com.twin.app.shoptime/src/utils/asyncPanelQueueExamples.js + com.twin.app.shoptime/src/utils/compatibleAsyncPanelExamples.js 📝 수정된 파일: ~ com.twin.app.shoptime/src/actions/actionTypes.js ~ com.twin.app.shoptime/src/actions/queuedPanelActions.js ~ com.twin.app.shoptime/src/reducers/panelReducer.js 🔧 주요 변경 내용: • 타입 시스템 안정성 강화 • 핵심 비즈니스 로직 개선 • 공통 유틸리티 함수 최적화 • 대규모 기능 개발 • 모듈 구조 개선
This commit is contained in:
@@ -14,7 +14,12 @@ const initialState = {
|
||||
totalProcessed: 0, // 총 처리된 액션 수
|
||||
failedCount: 0, // 실패한 액션 수
|
||||
averageProcessingTime: 0 // 평균 처리 시간
|
||||
}
|
||||
},
|
||||
|
||||
// [251106] 비동기 액션 관련 상태
|
||||
asyncActions: {}, // 실행 중인 비동기 액션들 { actionId: { ... } }
|
||||
completedAsyncActions: [], // 완료된 비동기 액션 ID들
|
||||
failedAsyncActions: [], // 실패한 비동기 액션 ID들
|
||||
};
|
||||
|
||||
// last one will be on top
|
||||
@@ -332,6 +337,102 @@ export const panelsReducer = (state = initialState, action) => {
|
||||
};
|
||||
}
|
||||
|
||||
// [251106] 비동기 패널 액션 관련 reducer 케이스들
|
||||
case types.ENQUEUE_ASYNC_PANEL_ACTION: {
|
||||
console.log('[panelReducer] 🟠 ENQUEUE_ASYNC_PANEL_ACTION', {
|
||||
actionId: action.payload.id,
|
||||
timestamp: action.payload.timestamp,
|
||||
});
|
||||
|
||||
return {
|
||||
...state,
|
||||
asyncActions: {
|
||||
...state.asyncActions,
|
||||
[action.payload.id]: {
|
||||
...action.payload,
|
||||
status: 'running',
|
||||
startTime: Date.now(),
|
||||
}
|
||||
},
|
||||
queueError: null, // 에러 초기화
|
||||
};
|
||||
}
|
||||
|
||||
case types.COMPLETE_ASYNC_PANEL_ACTION: {
|
||||
console.log('[panelReducer] ✅ COMPLETE_ASYNC_PANEL_ACTION', {
|
||||
actionId: action.payload.actionId,
|
||||
timestamp: action.payload.timestamp,
|
||||
});
|
||||
|
||||
const asyncAction = state.asyncActions[action.payload.actionId];
|
||||
const executionTime = asyncAction ? Date.now() - asyncAction.startTime : 0;
|
||||
|
||||
// 실행 중인 액션에서 제거하고 완료된 액션에 추가
|
||||
const newAsyncActions = { ...state.asyncActions };
|
||||
delete newAsyncActions[action.payload.actionId];
|
||||
|
||||
return {
|
||||
...state,
|
||||
asyncActions: newAsyncActions,
|
||||
completedAsyncActions: [
|
||||
...state.completedAsyncActions,
|
||||
{
|
||||
actionId: action.payload.actionId,
|
||||
result: action.payload.result,
|
||||
executionTime,
|
||||
completedAt: action.payload.timestamp,
|
||||
}
|
||||
].slice(-100), // 최근 100개만 유지
|
||||
queueError: null,
|
||||
queueStats: {
|
||||
...state.queueStats,
|
||||
totalProcessed: state.queueStats.totalProcessed + 1,
|
||||
averageProcessingTime: Math.round(
|
||||
((state.queueStats.averageProcessingTime * state.queueStats.totalProcessed) + executionTime) /
|
||||
(state.queueStats.totalProcessed + 1) * 100
|
||||
) / 100,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case types.FAIL_ASYNC_PANEL_ACTION: {
|
||||
console.log('[panelReducer] ❌ FAIL_ASYNC_PANEL_ACTION', {
|
||||
actionId: action.payload.actionId,
|
||||
error: action.payload.error?.message || 'Unknown error',
|
||||
timestamp: action.payload.timestamp,
|
||||
});
|
||||
|
||||
const asyncAction = state.asyncActions[action.payload.actionId];
|
||||
const executionTime = asyncAction ? Date.now() - asyncAction.startTime : 0;
|
||||
|
||||
// 실행 중인 액션에서 제거하고 실패한 액션에 추가
|
||||
const newAsyncActions = { ...state.asyncActions };
|
||||
delete newAsyncActions[action.payload.actionId];
|
||||
|
||||
return {
|
||||
...state,
|
||||
asyncActions: newAsyncActions,
|
||||
failedAsyncActions: [
|
||||
...state.failedAsyncActions,
|
||||
{
|
||||
actionId: action.payload.actionId,
|
||||
error: action.payload.error,
|
||||
executionTime,
|
||||
failedAt: action.payload.timestamp,
|
||||
}
|
||||
].slice(-100), // 최근 100개만 유지
|
||||
queueError: {
|
||||
actionId: action.payload.actionId,
|
||||
error: action.payload.error,
|
||||
timestamp: action.payload.timestamp,
|
||||
},
|
||||
queueStats: {
|
||||
...state.queueStats,
|
||||
failedCount: state.queueStats.failedCount + 1,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user