[LiveComponent] Add keep-alive modifier to polling plugin#2898
[LiveComponent] Add keep-alive modifier to polling plugin#2898norkunas wants to merge 1 commit intosymfony:2.xfrom
keep-alive modifier to polling plugin#2898Conversation
📊 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.
We should remove this event listener on controller's disconnect
There was a problem hiding this comment.
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.