capacitor-vue-ionicv4-app icon indicating copy to clipboard operation
capacitor-vue-ionicv4-app copied to clipboard

Keep-alive - activated does not seem to be triggered

Open joeSaad opened this issue 5 years ago • 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.

joeSaad avatar Jul 24 '20 20:07 joeSaad

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

aaronksaunders avatar Jul 24 '20 22:07 aaronksaunders

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

joeSaad avatar Jul 25 '20 01:07 joeSaad

Keep-alive only works with dynamic components according to the documentation. What are you trying to accomplish?

On Fri, Jul 24, 2020 at 9:57 PM Joe Saad [email protected] wrote:

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

Please advise, thanks again

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/aaronksaunders/capacitor-vue-ionicv4-app/issues/10#issuecomment-663793341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEAFGJOG3F32EIDYUNXHILR5I3Y3ANCNFSM4PHBNF7Q .

--

--

Aaron K. Saunders CEO Clearly Innovative Inc - Luma Lab - In3 [email protected] www.clearlyinnovative.com www.In3DC.com

This email message and any attachment(s) are for the sole use of the intended recipient(s) and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient(s), please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachment(s) to the original message.

aaronksaunders avatar Jul 25 '20 01:07 aaronksaunders

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

joeSaad avatar Jul 25 '20 02:07 joeSaad

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

joeSaad avatar Jul 25 '20 02:07 joeSaad

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

aaronksaunders avatar Jul 25 '20 19:07 aaronksaunders

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.

joeSaad avatar Jul 27 '20 13:07 joeSaad