Subscribe on changes!

Allow including/excluding by key in keep-alive

avatar
Sep 10th 2020

What problem does this feature solve?

Want more flexible caching components

What does the proposed API look like?

<keep-alive include="detail-id-1,detail-id-2">
        <component :is="Component" :key="key" />
 </keep-alive>

Source code:232 line

  const name = getName(comp);
  const { include, exclude, max } = props;

  if (
    (include && (!name || !matches(include, name))) ||
    (exclude && name && matches(exclude, name))
  ) {
    return (current = vnode)
  }

  const key = vnode.key == null ? comp : vnode.key
  const cachedVNode = cache.get(key)

modify:

  const name = vnode.key || getName(comp)

The "key" value is preferred as the include or exclude condition

avatar
Sep 10th 2020

This was asked for Vue 2 https://github.com/vuejs/vue/issues/8028

avatar
Mar 17th 2021
avatar
Nov 5th 2021

Closed, tracking here vuejs/rfcs#284

Any progress?

avatar
Mar 17th 2022

Closed, tracking here vuejs/rfcs#284

Is there anything holding this up?

avatar
Sep 21st 2022

三年又三年