Skip to content

Commit 5d6674e

Browse files
committed
Run callable before flushing, revert default
1 parent 3d59fe0 commit 5d6674e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Whether the session should be closed when the event stream begins.
2929
* This is useful to allow other requests to be processed while the event stream is being sent.
3030
*/
31-
'shouldCloseSession' => false,
31+
'shouldCloseSession' => true,
3232

3333
/**
3434
* The name of the signals variable that will be injected into Datastar templates.

src/models/Settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Settings extends Model
1818
* Whether the session should be closed when the event stream begins.
1919
* This is useful to allow other requests to be processed while the event stream is being sent.
2020
*/
21-
public bool $shouldCloseSession = false;
21+
public bool $shouldCloseSession = true;
2222

2323
/**
2424
* The name of the signals variable that will be injected into Datastar templates.

src/services/SseService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ public function getEventStream(?callable $callable = null): Response
7979
session_write_close();
8080
}
8181

82+
if (is_callable($callable)) {
83+
$callable();
84+
}
85+
8286
echo $this->getEventOutput();
8387
if (ob_get_contents()) {
8488
ob_flush();
8589
}
8690
flush();
8791

88-
if (is_callable($callable)) {
89-
$callable();
90-
}
91-
9292
// Return an array to prevent Yii from throwing an exception.
9393
return [];
9494
};

0 commit comments

Comments
 (0)