From 837cd10853d16270b724a30015f1fb25e2e20c29 Mon Sep 17 00:00:00 2001 From: thgee Date: Sun, 25 Aug 2024 14:34:01 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../providers/AssetLoaderContextProvider.tsx | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 packages/service/src/common/providers/AssetLoaderContextProvider.tsx diff --git a/packages/service/src/common/providers/AssetLoaderContextProvider.tsx b/packages/service/src/common/providers/AssetLoaderContextProvider.tsx deleted file mode 100644 index 462bedde..00000000 --- a/packages/service/src/common/providers/AssetLoaderContextProvider.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import React, { useCallback, useReducer, ReactNode } from "react"; -import { - IAssetLoaderState, - AssetLoaderContext, -} from "../contexts/AssetLoaderContext"; - -interface AssetLoaderContextProviderProps { - children: ReactNode; -} - -type AssetLoaderAction = { type: "LOAD_START" } | { type: "LOAD_DONE" }; - -const assetLoaderReducer = ( - state: IAssetLoaderState, - action: AssetLoaderAction, -): IAssetLoaderState => { - switch (action.type) { - case "LOAD_START": - return { - ...state, - status: "loading", - percentage: 0, - maxCount: state.maxCount + 1, - }; - case "LOAD_DONE": - return { - ...state, - percentage: ((state.loadedCount + 1) / state.maxCount) * 100, - loadedCount: state.loadedCount + 1, - }; - } -}; - -const initialState: IAssetLoaderState = { - status: "idle", - loadedCount: 0, - maxCount: 0, - percentage: 0, -}; - -export const AssetLoaderContextProvider: React.FC< - AssetLoaderContextProviderProps -> = ({ children }) => { - const [state, dispatch] = useReducer(assetLoaderReducer, initialState); - - const onLoadStart = useCallback(() => { - dispatch({ type: "LOAD_START" }); - }, []); - - const onLoadedData = useCallback(() => { - dispatch({ type: "LOAD_DONE" }); - }, []); - - return ( - - {children} - - ); -};