{"repo":"razshare/sveltekit-sse","free":true,"listed":false,"github":"https://github.com/razshare/sveltekit-sse","clone":"git clone https://github.com/razshare/sveltekit-sse.git","description":"Server Sent Events with SvelteKit","language":"JavaScript","stars":455,"topics":["server-sent-events","svelte","sveltekit","sse"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"SvelteKit SSE This library provides an easy way to produce and consume server sent events. Install with: Produce your server sent events with Consume them on your client with Your application will render something like this Locking All streams are locked server side by default, meaning the server will keep the connection alive indefinitely. The locking mechanism is achieved through a Writable , which you can access from the start function. The above code emit s the hello world string with the message event name and closes the stream after 2 seconds. You should not send any more messages after invoking lock.set(false) otherwise your emit function will return an error.\\ The resulting error is wrapped in Unsafe , which you can manage using conditionals Stop You can stop a connection and run code when a connection is stopped - by returning a function from start() - or by setting options::stop() and calling lock.set(false) Both ways are valid. [!NOTE] In the second case, using options::stop() , your code will also run if the client itself cancels the connection. Cleanup Whenever the client disconnects from the stream, the server will detect that event and trigger your stop function.\\ This behavior has a delay of 30 seconds by default.\\ This is achieved through a ping mechanism, by periodically ( every 30 seconds by default ) sending a ping event to the client. You can customize that ping event's time interval You can also forcefully detect disconnected clients by simply emitting a","default_branch":null,"files":null,"tree":[],"storefront":"/r/razshare","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/razshare/sveltekit-sse/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}