Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vue3): Add Vue3 KeepAlive Component Support #2158

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cnpap
Copy link

@cnpap cnpap commented Dec 28, 2024

Description: This PR adds support for Vue's KeepAlive component in Inertia.js Vue3 adapter, allowing for more efficient component caching and state preservation.

Features

  • Added keepAliveResolver prop to configure KeepAlive behavior per component
  • Implemented KeepAliveOptions interface with the following options:
  • enabled: Toggle KeepAlive functionality
  • includes: Array of component names to cache
  • maxLength: Maximum number of components to keep alive (defaults to 10)
  • Enhanced component key management using component names and optional URL-based IDs
  • Removed unused layout ref and simplified component rendering logic

杨伟杰 added 3 commits December 29, 2024 01:30
- Add KeepAliveOptions interface for configuration
- Implement keepAliveResolver prop for component-level control
- Add component name and ID based key management
- Support max length and includes options for KeepAlive
Improve key generation logic in swapComponent to ensure unique keys when navigating between pages.
This fixes the failing tests by:
- Using timestamp + random number for non-preserved state
- Maintaining explicit handling of KeepAliveId
- Ensuring consistent behavior with preserveState
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