Skip to content

Commit 533ab85

Browse files
committed
bugfix/safari_streaming - handle Safari closing the stream connection when the window is hidden
1 parent 6f1b0df commit 533ab85

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

examples/Streaming/Streaming.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ let handleIndex ctx = task {
4040

4141
Text.h1 "Example: Streaming"
4242

43-
Elem.input [ Attr.id "streamDisplayBadApple"; Attr.typeRadio; Attr.value Consts.displaySignalValueBadApple
43+
Elem.input [ Attr.id "streamDisplayBadApple"
44+
Attr.typeRadio
45+
Attr.value Consts.displaySignalValueBadApple
4446
Ds.bind Consts.displaySignalName ]
4547
Elem.label [ Attr.for' "streamDisplayBadApple" ] [ Text.raw "Bad Apple" ]
4648

47-
Elem.input [ Attr.id "streamDisplayGuids"; Attr.typeRadio; Attr.value Consts.displaySignalValueUsers
49+
Elem.input [ Attr.id "streamDisplayGuids"
50+
Attr.typeRadio
51+
Attr.value Consts.displaySignalValueUsers
4852
Ds.bind Consts.displaySignalName ]
4953
Elem.label [ Attr.for' "streamDisplayGuids" ] [ Text.raw "Viewers" ]
5054

@@ -73,6 +77,7 @@ let handleStream : HttpHandler = (fun ctx -> task {
7377
let user = user |> ValueOption.get
7478

7579
do! handleViewChange ctx
80+
do! Response.sseMergeSignal (sseHandler, Consts.displaySignalName, Consts.displaySignalValueBadApple)
7681

7782
try
7883
try

src/Falco.Datastar/Ds.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ type Ds =
454454
expressions |> String.concat " ; "
455455

456456
/// <summary>
457-
/// An attribute that should be placed in the &lt;body&gt; when creating a streaming app to avoid the issue explained here:
457+
/// An attribute that should be added to the &lt;body&gt; when creating a streaming app to avoid the issue explained here:
458458
/// https://stackoverflow.com/questions/8788802/prevent-safari-loading-from-cache-when-back-button-is-clicked
459459
/// </summary>
460460
static member safariStreamingFix = Attr.create "data-on-pageshow.window" "evt?.persisted && window.location.reload()"

0 commit comments

Comments
 (0)