Menu

1 / 2

Our window reloads every time you open it, so our event stream opens with 203 frames

DEV Community: node·Daniel Pertu·about 17 hours ago
#vqejz4S7
#devtonodejs#devto#dev#fullscreen#monitor
Reading 0:00
15s threshold

Notifio is a desktop monitor for rental listings. Inside the Electron main process there is an Express server, the UI is a React app it serves over HTTP, and the renderer talks to it on 127.0.0.1 with no preload script and no IPC .

The live half of that is one server-sent events endpoint. It has an unusual constraint on it: the window reloads itself every single time it is opened from the tray . A fresh React tree, an empty store, no memory of the twelve hours the monitor spent working while the window was hidden.

A stream of changes is worthless to a client in that position. So the stream opens with the past:

app . get ( ' /api/events ' , ( req : Request , res : Response ) => { res . setHeader ( ' Content-Type ' , ' text/event-stream ' ); res . setHeader ( ' Cache-Control ' , ' no-cache ' ); res . setHeader ( ' Connection ' , ' keep-alive ' ); res .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.