Files
AlwaysHTTPS/app/scripts.babel/chromereload.js
Zhigang Fang 0f4efc1e12 Initial Commit
2016-06-02 17:48:36 +08:00

24 lines
591 B
JavaScript

'use strict';
// Reload client for Chrome Apps & Extensions.
// The reload client has a compatibility with livereload.
// WARNING: only supports reload command.
const LIVERELOAD_HOST = 'localhost:';
const LIVERELOAD_PORT = 35729;
const connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload');
connection.onerror = error => {
console.log('reload connection got error:', error);
};
connection.onmessage = e => {
if (e.data) {
const data = JSON.parse(e.data);
if (data && data.command === 'reload') {
chrome.runtime.reload();
}
}
};