Jump to another example:
Basics
Store
Composables
Events
Forms
Features
Feature Showcase: Streaming
Stream server chunks in real time with v-stream and livue.stream().
How it works
This example uses WithStreaming on the PHP component and
v-stream targets in the template.
The button calls livue.stream('generatePreview')
to receive chunks progressively.
v-stream target (append)
Press "Start streaming" to receive chunks from the server.
v-stream.replace target
Ready
Server status: Ready
Final server value
No final text yet.
Streaming in progress...
app/LiVue/StreamingDemo.php
use LiVue\Features\SupportStreaming\WithStreaming;
public function generatePreview(): void
{
$this->stream('output', '', true);
foreach ($tokens as $token) {
$this->stream('output', $token . ' ');
}
}
resources/views/livue/streaming-demo.blade.php
<div v-stream="'output'"></div>
<p v-stream.replace="'status'"></p>
<button @click="livue.stream('generatePreview')">
Start streaming
</button>