fix: disable SSE request cancellation for live game updates
The default Datastar requestCancellation:'auto' was causing SSE connections to be cancelled whenever users interacted with the page (making moves, sending chat messages, etc.), breaking live updates.
This commit is contained in:
@@ -33,7 +33,7 @@ templ GamePage(sg *snake.SnakeGame, mySlot int, messages []chat.Message, chatCfg
|
||||
<main
|
||||
class="snake-wrapper flex flex-col items-center gap-4 p-4"
|
||||
data-signals={ `{"chatMsg":""}` }
|
||||
data-init={ datastar.GetSSE("/snake/%s/events", gameID) }
|
||||
data-init={ fmt.Sprintf("@get('/snake/%s/events',{requestCancellation:'disabled'})", gameID) }
|
||||
data-on:keydown__throttle.100ms={ keydownScript(gameID) }
|
||||
tabindex="0"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user