-
-
Notifications
You must be signed in to change notification settings - Fork 367
[LiveComponent] Add keep-alive
modifier to polling plugin
#2898
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
base: 2.x
Are you sure you want to change the base?
Conversation
📊 Packages dist files size differenceThanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
|
Oh, livewire keep-alive is a reverse, as @smnandre said in the issue.. How we should name it? |
I'm not sure this should be a modifier... so maybe name does not matter :) |
And if not a modifier, then what it should be? |
document.addEventListener('visibilitychange', () => { | ||
if (document.hidden) { | ||
this.pollingDirector.stopAllPolling(); | ||
} else { | ||
this.pollingDirector.startAllPolling(); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this event listener on controller's disconnect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know, first let's agree on direction :) as @smnandre disagree about modifier
It should be the default behaviour. Not sure i see a valid usage for polls while the tab is in background |
Could it be considered as a BC? |
To me it's almost a bug if we send requests at fixed interval when the tab is in background or hidden :| --> https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API Problem will happen on every browser (except if we speak about big interval but then.. what is the point? what feature is provided by this behaviour ?) |
Maybe it's a game where something should still happen in background :D but it's ok for me doing this without modifier |
This is a naive implementation, which I think needs to be discussed.
I think the listener somehow somewhere should be detached when poll disconnects.
And the best solution would be to add it once for all polling, but I don't see how it is doable.