Skip to content

A simple API for consuming server-sent events (SSE) using an AsyncGenerator

Notifications You must be signed in to change notification settings

youssefm/stream-event-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stream-event-source

A simple API for consuming server-sent events (SSE) using an AsyncGenerator

Example usage, printing out events on the Wikimedia recent changes stream for 5 seconds:

const stream = streamEventSource(
  "https://stream.wikimedia.org/v2/stream/recentchange"
);

const now = Date.now();

for await (const event of stream) {
  console.log(event.event);
  console.log(event.data);

  if (Date.now() - now > 5000) {
    break;
  }
}

About

A simple API for consuming server-sent events (SSE) using an AsyncGenerator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published