sse

typescript
import { Controller, Sse, Headers } from '@nestjs/common';
import { interval, Observable } from 'rxjs';
import { map } from 'rxjs/operators';

interface FeedPayload {
  id: number;

Streaming Server-Sent Events into a Live React List with an EventSource Hook

react sse eventsource
by codesnips 3 tabs
typescript
import { Response } from 'express';

type Client = { id: number; res: Response };

const clients = new Map<string, Set<Client>>();
let nextId = 1;

SSE endpoint for server-to-browser events

realtime sse express
by codesnips 3 tabs
java
package com.example.notifications;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.io.IOException;

Live Browser Notifications with Spring Boot SseEmitter and a Broadcaster Service

spring-boot sse server-sent-events
by codesnips 3 tabs
javascript
const { EventEmitter } = require('events');

const HIGH_WATER_MARK = 1 << 20; // 1 MiB of buffered bytes per client

class SseHub extends EventEmitter {
  constructor() {

Broadcasting Events to Clients with Server-Sent Events on Node's http Module

nodejs sse server-sent-events
by codesnips 3 tabs
javascript
const { EventEmitter } = require('events');

class NotificationBus extends EventEmitter {
  constructor(bufferSize = 100) {
    super();
    this.setMaxListeners(0);

Server-Sent Events for Live Notifications with a Reconnectable EventSource Hook

sse server-sent-events eventsource
by codesnips 3 tabs
go
package sse

type Broker struct {
	subscribers map[chan []byte]struct{}
	subscribe   chan chan []byte
	unsubscribe chan chan []byte

Server-Sent Events in Go with http.Flusher and Context Cancellation

sse streaming http
by codesnips 3 tabs
java
@RestController
@RequestMapping("/api/notifications")
public class NotificationController {

    private final SseEmitterRegistry registry;
    private final NotificationService service;

Push Live Notifications with Server-Sent Events in Spring Boot

spring-boot sse server-sent-events
by codesnips 3 tabs
go
package realtime

import (
  "fmt"
  "net/http"
  "time"

Server-Sent Events (SSE) with heartbeats and client cleanup

go http sse
by Leah Thompson 1 tab
ruby
require 'set'
require 'json'

class Broadcaster
  def initialize
    @mutex = Mutex.new

Stream Server-Sent Events from a Sinatra Route With Keep-Alive Pings

sinatra sse streaming
by codesnips 3 tabs