Skip to content

Commit

Permalink
chore(issue-58): adding a new example
Browse files Browse the repository at this point in the history
  • Loading branch information
razshare committed Oct 6, 2024
1 parent 0463830 commit 498ec1c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/routes/issue-58/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- +page.svelte -->
<script>
import { source } from '$lib'
import { playwright } from '$lib/playwright/playwright'
const connection = source('/issue-58/events', {
options: {
method: 'GET',
},
})
const message = connection.select('message')
$: playwright.state.issue55.messages.push($message)
</script>

<h3>{$message}</h3>
22 changes: 22 additions & 0 deletions src/routes/issue-58/events/+server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { produce } from '$lib'
import { delay } from '$lib/delay.js'

export async function GET() {
return produce(
async function start({ emit }) {
// eslint-disable-next-line no-constant-condition
while (true) {
const { error } = emit('message', `${Date.now()}`)
if (error) {
return
}
await delay(1000)
}
},
{
stop() {
console.log('Client disconnected!!')
},
},
)
}

0 comments on commit 498ec1c

Please sign in to comment.