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

Keep-alive - activated does not seem to be triggered #10

Open
joeSaad opened this issue Jul 24, 2020 · 7 comments
Open

Keep-alive - activated does not seem to be triggered #10

joeSaad opened this issue Jul 24, 2020 · 7 comments

Comments

@joeSaad
Copy link

joeSaad commented Jul 24, 2020

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.

@aaronksaunders
Copy link
Owner

aaronksaunders commented Jul 24, 2020

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

@joeSaad
Copy link
Author

joeSaad commented Jul 25, 2020

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

@aaronksaunders
Copy link
Owner

aaronksaunders commented Jul 25, 2020 via email

@joeSaad
Copy link
Author

joeSaad commented Jul 25, 2020

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

@joeSaad
Copy link
Author

joeSaad commented Jul 25, 2020

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..

@aaronksaunders
Copy link
Owner

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

@joeSaad
Copy link
Author

joeSaad commented Jul 27, 2020

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.

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

No branches or pull requests

2 participants