📝 Added sandbox (code sketchbook)
This commit is contained in:
parent
b475595f7f
commit
b5daf18b1a
142 changed files with 100702 additions and 0 deletions
11
sandbox/vue_sse/vue_sse_front/public/index.js
Normal file
11
sandbox/vue_sse/vue_sse_front/public/index.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
const sse = new EventSource("http://localhost:8080/stream")
|
||||
const streamSection = document.querySelector('.stream-section')
|
||||
|
||||
sse.onmessage = (e) => {
|
||||
const node = document.createElement('li')
|
||||
node.textContent = e.data
|
||||
streamSection.appendChild(node)
|
||||
}
|
||||
|
||||
// stops stream after 30 seconds
|
||||
setTimeout(() => sse.close(), 30000)
|
||||
Loading…
Add table
Add a link
Reference in a new issue