You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we'd like to use the SSE trigger functionality to refresh small parts of a page. Every now and then two events are coming in during a very short amount of time, sometimes the second event arrives at the client at a time, at which the swapping of the first event has not finished yet (i.e. the element with the refresh-trigger has been removed already, but the new version of it does not exist in the DOM yet). In this case the second event does not trigger a refresh.
htmx:beforeCleanupElement is executed for div#item-1234 and its children
event refresh-item-1234 is received again, but the trigger sse:refresh-item-1234 is not having any effect because it does not exist
swapping of the first event happens and is finished, showing outdated data
Is there a way to delay the processing of the second event until there is no swapping progress?
One solution I have thought of is to not swap the entire div here, but instead a child div, such that div#item-1234 always stays present on the page.
But this does not help in cases where this is not possible, e.g. when htmx is currently in the progress loading the current page due to a full page swap via hx-boost, coming from another page. And this scenario is even more likely since swapping the complete page takes longer.
The text was updated successfully, but these errors were encountered:
We solved this by having the sse:refresh-item-1234 trigger always present on the page (in an outer element), this seems to work. The problem of an event arriving during page load remains unsolved for now, but it seems in our use cases this is less likely to happen.
Hi,
we'd like to use the SSE trigger functionality to refresh small parts of a page. Every now and then two events are coming in during a very short amount of time, sometimes the second event arrives at the client at a time, at which the swapping of the first event has not finished yet (i.e. the element with the refresh-trigger has been removed already, but the new version of it does not exist in the DOM yet). In this case the second event does not trigger a refresh.
Example:
Timeline observed via
htmx.logAll
:event refresh-item-1234
is receivedhtmx:beforeCleanupElement
is executed fordiv#item-1234
and its childrenevent refresh-item-1234
is received again, but the triggersse:refresh-item-1234
is not having any effect because it does not existIs there a way to delay the processing of the second event until there is no swapping progress?
One solution I have thought of is to not swap the entire div here, but instead a child div, such that
div#item-1234
always stays present on the page.But this does not help in cases where this is not possible, e.g. when htmx is currently in the progress loading the current page due to a full page swap via
hx-boost
, coming from another page. And this scenario is even more likely since swapping the complete page takes longer.The text was updated successfully, but these errors were encountered: