Skip to content

refactor: Improve tile management and WebSocket message processing architecture#70

Merged
kimgh06 merged 5 commits into
mainfrom
fix/animationbeforegettingtiles
Jan 9, 2026
Merged

refactor: Improve tile management and WebSocket message processing architecture#70
kimgh06 merged 5 commits into
mainfrom
fix/animationbeforegettingtiles

Conversation

@kimgh06

@kimgh06 kimgh06 commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

개요

타일 관리 시스템과 WebSocket 메시지 처리 로직을 리팩토링하여 코드 구조를 개선하고 유지보수성을 향상시켰습니다.

주요 변경사항

1. Zustand 스토어를 통한 타일 상태 관리 통합 (627d066)

  • 타일 데이터 관리를 Zustand 스토어로 이전
  • useTileStore를 통해 타일 상태를 중앙화
  • 성능 최적화를 위한 selector hooks 추가 (useTiles, useRenderTiles 등)

2. 타일 패딩 로직 개선 (a2625b6)

  • moveCursor 함수를 padtiles로 대체
  • 방향별 타일 패딩 로직을 더 명확하고 효율적으로 개선
  • 다양한 방향(UP, DOWN, LEFT, RIGHT, 대각선 등) 지원

3. 타일 처리 및 상태 관리 최적화 (3263fc2)

  • 타일 처리 로직을 최적화하여 성능 개선
  • 상태 관리 구조를 개선하여 데이터 흐름 명확화
  • 타일 업데이트 로직을 applyTileChanges로 통합

4. WebSocket 메시지 처리 개선 (b760d49)

  • useMessageHandler 커스텀 훅 구현
  • WebSocket 메시지 처리 로직을 별도 훅으로 분리하여 재사용성 향상
  • 메시지 핸들링 로직의 가독성 및 유지보수성 개선

5. 상수 중앙화 및 import 정리 (e7d0013)

  • FILL_CHAR 상수를 tileStore.ts로 중앙화
  • Play 컴포넌트의 import 문 정리 및 최적화
  • 코드 일관성 향상

기술적 개선사항

  • 상태 관리: Zustand를 활용한 중앙화된 상태 관리
  • 코드 구조: 관심사 분리를 통한 모듈화
  • 성능: Selector hooks를 통한 불필요한 리렌더링 방지
  • 유지보수성: 로직 분리 및 상수 중앙화로 코드 가독성 향상

테스트

  • 기존 기능이 정상적으로 동작하는지 확인
  • 타일 렌더링 및 업데이트 로직 검증
  • WebSocket 메시지 처리 정상 동작 확인

- Introduced a new tileStore using zustand for managing tile data, including tiles, renderTiles, and related state.
- Replaced local state management for tiles with store selectors to enhance performance and maintainability.
- Updated tile manipulation functions to utilize the store, improving the clarity and efficiency of tile updates.
- Refactored CanvasDashboard and CanvasRenderComponent to retrieve tileSize and tiles directly from the store, streamlining component logic.
- Updated the Play component to replace the moveCursor function with padtiles for handling tile padding based on cursor movement.
- Refactored the CanvasRenderComponent to apply padding before animations, improving the responsiveness of tile updates.
- Enhanced the tileStore to include the new padtiles function, allowing for more flexible tile manipulation based on direction.
- Added new direction types to the position definitions for better clarity in tile padding operations.
…nent

- Introduced useCallback for tile processing functions to enhance performance and prevent unnecessary re-renders.
- Refactored the replaceTiles and createWorkerPromises functions to utilize zustand store for improved state management.
- Updated the handleWebSocketMessage function to integrate a new message handler for better organization and clarity.
- Added console logs for performance tracking during tile updates, aiding in debugging and optimization efforts.
…processing

- Introduced a new custom hook, useMessageHandler, to centralize and streamline WebSocket message handling in the Play component.
- Replaced the deprecated useMessageProcess hook, enhancing clarity and organization of message processing logic.
- Updated the Play component to utilize the new message handler, improving maintainability and performance.
- Refactored tile processing logic to leverage the new handler for better integration with WebSocket events.
…component

- Moved the FILL_CHAR constant to the tileStore for better accessibility across components.
- Updated the Play component to import FILL_CHAR from the tileStore, improving code organization and maintainability.
- Removed redundant import statements to streamline the Play component's dependencies.
@kimgh06 kimgh06 merged commit 63a0047 into main Jan 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant