libodonjs icon indicating copy to clipboard operation
libodonjs copied to clipboard

stream support

Open pwFoo opened this issue 7 years ago • 0 comments

simple stream support

		stream(endpoint, callback) {
			let url = 'https://mastodon.social' + '/api/v1/streaming/' + endpoint	// ToDo: move server, streaming, api version to class variables
			let stream = new EventSource(url);
			stream.addEventListener('update', callback, false);
		}

Example callback

app.stream('public', function(stream) {
	var res = JSON.parse(stream.data);
	console.log(res); // new element in stream
})

But EventSocket fallback needed for IE / Edge!

I plan some more changes to simplify the libodon and add features.

pwFoo avatar Oct 11 '18 20:10 pwFoo