WebSocket経由でページ作成する
meganii.icon
https://gyazo.com/36d6a0eac747c0b163f7c6e5878c441f
code:typescript
const project = 'hogehoge-project'
const title = 'Test page from websoket'
const { render, dispose } = useStatusBar()
let socket: Socket | undefined
try {
render(
{ type: "spinner" },
{ type: "text", text: Updating... },
)
socket = await makeSocket()
await patch(project, title, (lines) => [
...lines.splice(1).map(line => line.text),
'updated'
], { socket })
} catch (e: unknown) {
console.error(e)
} finally {
if (socket) {
await disconnect(socket)
}
await sleep(1000)
dispose()
}