malekim / v-idle

A Vue.js plugin to detect idle/non-active users
https://malekim.github.io/v-idle/
MIT License
70 stars 8 forks source link

Timer with onremind but no onIdle will get garbage collected? #25

Open sookyee opened 3 years ago

sookyee commented 3 years ago

Not sure if its a bug, but I used two v-idle timers, one is a global timer where it is set on a continuous loop, and when onRemind of this timer is called, will open a popup that shows another v-idle timer. The onIdle function of this popup timer will do the actual logging out of the user, so I didn't need an onIdle function for the first timer.

However, if the page is not in focus for a while, the first timer will stop counting down, hence the onremind will never be called and the popup won't show. I spent a lot of time debugging this, and eventually managed to get the first timer to always countdown by specifying onIdle on the first timer as well.

Of course, I could use only one timer, and when onRemind is called, write some javascript to move the global timer to the popup, but I figured it'll be easier to specify timers in two different places in html instead.

Just a suggestion to perhaps make onIdle not compulsory for all v-idle timers ? Thanks.

malekim commented 7 months ago

@sookyee just found some time to fix all issues, can you check if it's still an issue? I tried to reproduce it, but I couldn't