refactor: 메모리 누수 정리 및 타이머 관리 개선, 이벤트 리스너 제거 함수 추가

This commit is contained in:
“hyeonggkim”
2025-11-14 16:47:38 +09:00
parent ffa89ffbb6
commit ae7fb5fd60
10 changed files with 283 additions and 12 deletions

View File

@@ -7,11 +7,13 @@ export const useLoadingStore = defineStore('loadingStore', () => {
const isPAssApiLoading = ref(false)
// 컴포넌트별 로딩 표기 - Map 대신 일반 객체 사용
const localLoadings = ref<Record<string, { active: boolean }>>({})
const apiLoadingTimeoutId = ref<ReturnType<typeof setTimeout> | null>(null)
/**
* 로딩 상태 초기화
*/
const initializeStore = () => {
localLoadings.value = {}
hasApiCallStarted.value = false
isPAssApiLoading.value = false
@@ -34,10 +36,18 @@ export const useLoadingStore = defineStore('loadingStore', () => {
fullLoading.value = false
}
}
const finishApiLoading = () => {
setTimeout(() => {
// 이전 타이머가 있으면 정리
if (apiLoadingTimeoutId.value) {
clearTimeout(apiLoadingTimeoutId.value)
apiLoadingTimeoutId.value = null
}
apiLoadingTimeoutId.value = setTimeout(() => {
hasApiCallStarted.value = false
isPAssApiLoading.value = true
apiLoadingTimeoutId.value = null
}, 300)
}