Skip to content

Support for Server-Sent Events (SSE) #87

@apla

Description

@apla

For our project we would like to use SSE. Currently, code to activate SSE for LiveReload 3.0.0 is quite simple:

if (LiveReload) {
	LiveReload.connector.disconnect();
}

var source = new EventSource(url);

source.addEventListener ('reload', function (evt) {
	var files;
	try { files = JSON.parse (evt.data); } catch (e) { return; }

	if (LiveReload) {
		files.forEach (function (file) {
			LiveReload.performReload ({path: file})
		});
	} else {
		location.reload ();
	}
});

source.addEventListener ('alert', function (evt) {
	console.log ('alert event', evt);
	if (LiveReload) {
		LiveReload.performAlert (evt.data);
	}
});

Unfortunately, this not works with minified version nor version 3.0.1. I would like to make it works without LiveReload.connector.disconnect() if that's fine for you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions