aaronksaunders/capacitor-vue-ionicv4-app

Keep-alive - activated does not seem to be triggered

joeSaad opened this issue · 7 comments

First, thanks for this repo, it is very helpful and comes in handy.

This is more of a question, I tried to wrap my ion-vue-router in <keep-alive> tags and am trying to get activated() method to work in any of the page routes within this repo and it does not seem to be triggered.
Could you please advise on how to use <keep-alive> with <ion-vue-router> and get those activated() and deactivated() methods to work?

Thanks in advance.

please send a sample project or show more source code so I can understand what you are trying to do. There are no dynamic components so keep-alive wont work

Sure. Thanks for the prompt reply:
I have used this same repo with the following changes:

App.vue

    <keep-alive>
      <ion-vue-router />
    </keep-alive>

CameraPage.vue

methods: {},
activated(){
   console.log('Component activated')
}

the activated component doesn't seem to work with the ion-vue-router, however when I created another app using vue cli, I can see that activated works just fine with regular vue-router when I have

<keep-alive>
   <router-view/>
</keep-alive>

Please advise, thanks again

I just wanted activated to be triggered, every time i get to that component

Things work as expected when i try using <router-view /> instead of <ion-vue-router /> but I really want o use ion-vue-router but the problem is ion-vue-router does not seem to get activated() triggered unlike regular router-view which gets it triggered every time..

you should be able to use mounted and beforeDestroy instead. I believe activated and deactivated were introduced to support dynamic components... you are not using dynamic components you are just looking for access to specific lifecycles

I was only using this repo as an example. But my actual repo has <keep-alive> and activated() in the dynamic components and it already had <router-view /> and all is working as expected but now i am moving towards ionic usage and exchanging to <ion-vue-router /> doesn't make activated() to work anymore.