Keep-alive based on custom condition

Hey guys… please anyone…

I have a use-case for keep-alive where the condition on which I have to keep the component alive is based on user input.
As of now, keep-alive supports include and exclude props that check component name.
Is there any way I can keep-alive components based on my condition?

I’m looking for something like following:

    <keep-alive :if="myCondition">
      <component v-bind:is="currentTabComponent"></component>
    </keep-alive>

Don’t think that’s possible, but maybe:

<keep-alive v-if="myCondition">
  <component v-bind:is="currentTabComponent"></component>
</keep-alive>

<component v-bind:is="currentTabComponent" v-else></component>
1 Like

thank you for the answer. That’s is the very basic thing I could do…
May be we can request for this feature…

I would also want this option… I need to be able to control cached content based on whether the page actually loaded correctly or not. I.e. if the page errored-out there is no reason to cache it…

I have created a topic to discuss the problem I am having here:

as of this moment i still don’t know how to gracefully handle this situation…