Open shiftgeist opened 1 year ago
Nest Docu
Server-Sent Events (SSE) (since v7.5.0) are used as follows:
Nest controller
@Sse('sse') sse(): Observable<MessageEvent> { return interval(1000).pipe(map((_) => ({ data: { hello: 'world' } }))); }
Client
const eventSource = new EventSource('/sse'); eventSource.onmessage = ({ data }) => { console.log('New message', JSON.parse(data)); };
Full Example from Nest: nestjs/nest/sample/28-sse
Nest Docu
Server-Sent Events (SSE) (since v7.5.0) are used as follows:
Nest controller
Client
Full Example from Nest: nestjs/nest/sample/28-sse