@intuitionrobotics/thunderstorm
Version:
25 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectivityModule = void 0;
const ts_common_1 = require("@intuitionrobotics/ts-common");
const thunder_dispatcher_1 = require("../core/thunder-dispatcher");
class ConnectivityModule_Class extends ts_common_1.Module {
constructor() {
super("ConnectivityModule");
this.dispatch_onConnectivityChange = new thunder_dispatcher_1.ThunderDispatcher('__onConnectivityChange');
this.isConnected = () => this.connected;
this.handleConnectionChange = () => {
this.connected = this.getConnectivityStatus();
this.dispatch_onConnectivityChange.dispatchModule();
this.dispatch_onConnectivityChange.dispatchUI();
};
this.getConnectivityStatus = () => navigator.onLine;
this.connected = this.getConnectivityStatus();
}
init() {
window.addEventListener('online', this.handleConnectionChange);
window.addEventListener('offline', this.handleConnectionChange);
}
}
exports.ConnectivityModule = new ConnectivityModule_Class();
//# sourceMappingURL=ConnectivityModule.js.map