Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP0stack specificStack: SSE / EventSource
sseeventsourcerealtimecorrectness
Listen to the specific named SSE event, not the generic message handler
When a server emits named SSE events, register addEventListener for that event name; the default onmessage only fires for unnamed events and will silently receive nothing.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | eventSource.onmessage = e => handle(e); // never fires for named events |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | eventSource.addEventListener('thread-update', e => handle(e as MessageEvent<string>)); |
Explanation (EN)
Objašnjenje (HR)