Build an SSE stream

Name and version events

Design event names and payloads that can evolve without making every client guess what changed.

9 minute lesson

~~~

Start from the behavior you can observe. The board emits incident.created and incident.updated with an event id and a payload version instead of a generic message blob.

A live feed is an API. Stable names, identifiers, timestamps, and versioned payload shapes make it debuggable. The useful target is not encyclopedic coverage. Make one deliberate choice, observe its consequences, and know which requirement would make you revise it.

It is tempting to mirror internal database rows directly into the public stream. That trades a clear decision for an assumption you will eventually have to debug. The stronger move is to define a small event envelope with a stable type, id, occurred-at time, version, and documented payload. Make the boundary explicit in code and in the project notes.

Tie the decision back to the larger job: Build an SSE feed that reconnects cleanly and can repair a gap instead of merely looking live in one browser tab. Record enough evidence that another developer can repeat the result without relying on your memory.

Write three event examples and show how an older client ignores a new optional field safely. Repeat it once with an invalid or hostile condition and write down the boundary the failure revealed.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →