Skip to content

feat(keep-alive): allow custom caching strategy #8701

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
460 changes: 366 additions & 94 deletions packages/runtime-core/__tests__/components/KeepAlive.spec.ts

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion packages/runtime-core/src/apiLifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import { toHandlerKey } from '@vue/shared'
import { DebuggerEvent, pauseTracking, resetTracking } from '@vue/reactivity'
import { LifecycleHooks } from './enums'

export { onActivated, onDeactivated } from './components/KeepAlive'
export {
onActivated,
onDeactivated,
onBeforeActivate,
onBeforeDeactivate
} from './components/KeepAlive'

export function injectHook(
type: LifecycleHooks,
Expand Down
11 changes: 11 additions & 0 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,19 @@ export interface ComponentInternalInstance {
* @internal
*/
[LifecycleHooks.RENDER_TRIGGERED]: LifecycleHook

/**
* @internal
*/
[LifecycleHooks.BEFORE_ACTIVATE]: LifecycleHook
/**
* @internal
*/
[LifecycleHooks.ACTIVATED]: LifecycleHook
/**
* @internal
*/
[LifecycleHooks.BEFORE_DEACTIVATE]: LifecycleHook
/**
* @internal
*/
Expand Down Expand Up @@ -562,7 +571,9 @@ export function createComponentInstance(
u: null,
um: null,
bum: null,
bda: null,
da: null,
ba: null,
a: null,
rtg: null,
rtc: null,
Expand Down
8 changes: 8 additions & 0 deletions packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import {
onRenderTracked,
onBeforeUnmount,
onUnmounted,
onBeforeActivate,
onActivated,
onBeforeDeactivate,
onDeactivated,
onRenderTriggered,
DebuggerHook,
Expand Down Expand Up @@ -514,7 +516,9 @@ interface LegacyOptions<
mounted?(): void
beforeUpdate?(): void
updated?(): void
beforeActivate?(): void
activated?(): void
beforeDeactivate?(): void
deactivated?(): void
/** @deprecated use `beforeUnmount` instead */
beforeDestroy?(): void
Expand Down Expand Up @@ -635,7 +639,9 @@ export function applyOptions(instance: ComponentInternalInstance) {
mounted,
beforeUpdate,
updated,
beforeActivate,
activated,
beforeDeactivate,
deactivated,
beforeDestroy,
beforeUnmount,
Expand Down Expand Up @@ -817,7 +823,9 @@ export function applyOptions(instance: ComponentInternalInstance) {
registerLifecycleHook(onMounted, mounted)
registerLifecycleHook(onBeforeUpdate, beforeUpdate)
registerLifecycleHook(onUpdated, updated)
registerLifecycleHook(onBeforeActivate, beforeActivate)
registerLifecycleHook(onActivated, activated)
registerLifecycleHook(onBeforeDeactivate, beforeDeactivate)
registerLifecycleHook(onDeactivated, deactivated)
registerLifecycleHook(onErrorCaptured, errorCaptured)
registerLifecycleHook(onRenderTracked, renderTracked)
Expand Down
Loading