refactor: 메모리 누수 정리 및 타이머 관리 개선, 이벤트 리스너 제거 함수 추가
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user