Skip to content

Instantly share code, notes, and snippets.

@nuria
Last active November 26, 2019 19:27
Show Gist options
  • Save nuria/1c2f251810ac8d5df10c753f5d64f78a to your computer and use it in GitHub Desktop.
Save nuria/1c2f251810ac8d5df10c753f5d64f78a to your computer and use it in GitHub Desktop.
Event Streams consumption
// This is the EventStreams RecentChange stream endpoint
var url = 'https://stream.wikimedia.org/v2/stream/recentchange';
// Use EventSource (available in most browsers, or as an
// npm module: https://www.npmjs.com/package/eventsource)
// to subscribe to the stream.
var recentChangeStream = new EventSource(url);
// Print each event to the console
recentChangeStream.onmessage = function(message) {
//Parse the message.data string as JSON.
var event = JSON.parse(message.data);
console.log(event);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment