Change event names to be more descriptive. Fix some typos.

This commit is contained in:
Evelyn Eastmond 2019-01-16 20:17:19 -05:00
parent 6f9a4864e9
commit 7831256044
5 changed files with 21 additions and 14899 deletions

14878
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -575,6 +575,15 @@ class Runtime extends EventEmitter {
return 'PERIPHERAL_CONNECTED'; return 'PERIPHERAL_CONNECTED';
} }
/**
* Event name for reporting that a peripheral has been intentionally disconnected.
* This causes the status button in the blocks menu to indicate 'disconnected'.
* @const {string}
*/
static get PERIPHERAL_DISCONNECTED () {
return 'PERIPHERAL_DISCONNECTED';
}
/** /**
* Event name for reporting that a peripheral has encountered a request error. * Event name for reporting that a peripheral has encountered a request error.
* This causes the peripheral connection modal to switch to an error state. * This causes the peripheral connection modal to switch to an error state.
@ -585,21 +594,12 @@ class Runtime extends EventEmitter {
} }
/** /**
* Event name for reporting that a peripheral has been intentionally disconnected. * Event name for reporting that a peripheral connection has been lost.
* This causes the status button in the blocks menu to indicate 'disconnected'.
* @const {string}
*/
static get PERIPHERAL_DISCONNECT () {
return 'PERIPHERAL_DISCONNECT';
}
/**
* Event name for reporting that a peripheral has encountered a disconnect error.
* This causes a 'peripheral connection lost' error alert to display. * This causes a 'peripheral connection lost' error alert to display.
* @const {string} * @const {string}
*/ */
static get PERIPHERAL_DISCONNECT_ERROR () { static get PERIPHERAL_CONNECTION_LOST_ERROR () {
return 'PERIPHERAL_DISCONNECT_ERROR'; return 'PERIPHERAL_CONNECTION_LOST_ERROR';
} }
/** /**

View file

@ -81,7 +81,7 @@ class BLE extends JSONRPCWebSocket {
window.clearTimeout(this._discoverTimeoutID); window.clearTimeout(this._discoverTimeoutID);
} }
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT); this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECTED);
} }
/** /**
@ -209,7 +209,7 @@ class BLE extends JSONRPCWebSocket {
this.disconnect(); this.disconnect();
} }
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT_ERROR, { this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTION_LOST_ERROR, {
message: `Scratch lost connection to`, message: `Scratch lost connection to`,
extensionId: this._extensionId extensionId: this._extensionId
}); });

View file

@ -83,7 +83,7 @@ class BT extends JSONRPCWebSocket {
window.clearTimeout(this._discoverTimeoutID); window.clearTimeout(this._discoverTimeoutID);
} }
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT); this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECTED);
} }
/** /**
@ -96,7 +96,7 @@ class BT extends JSONRPCWebSocket {
sendMessage (options) { sendMessage (options) {
return this.sendRemoteRequest('send', options) return this.sendRemoteRequest('send', options)
.catch(e => { .catch(e => {
this._handleDisconnectError(e); this.handleDisconnectError(e);
}); });
} }
@ -150,7 +150,7 @@ class BT extends JSONRPCWebSocket {
this.disconnect(); this.disconnect();
} }
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT_ERROR, { this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTION_LOST_ERROR, {
message: `Scratch lost connection to`, message: `Scratch lost connection to`,
extensionId: this._extensionId extensionId: this._extensionId
}); });

View file

@ -124,11 +124,11 @@ class VirtualMachine extends EventEmitter {
this.runtime.on(Runtime.PERIPHERAL_REQUEST_ERROR, () => this.runtime.on(Runtime.PERIPHERAL_REQUEST_ERROR, () =>
this.emit(Runtime.PERIPHERAL_REQUEST_ERROR) this.emit(Runtime.PERIPHERAL_REQUEST_ERROR)
); );
this.runtime.on(Runtime.PERIPHERAL_DISCONNECT, () => this.runtime.on(Runtime.PERIPHERAL_DISCONNECTED, () =>
this.emit(Runtime.PERIPHERAL_DISCONNECT) this.emit(Runtime.PERIPHERAL_DISCONNECTED)
); );
this.runtime.on(Runtime.PERIPHERAL_DISCONNECT_ERROR, data => this.runtime.on(Runtime.PERIPHERAL_CONNECTION_LOST_ERROR, data =>
this.emit(Runtime.PERIPHERAL_DISCONNECT_ERROR, data) this.emit(Runtime.PERIPHERAL_CONNECTION_LOST_ERROR, data)
); );
this.runtime.on(Runtime.PERIPHERAL_SCAN_TIMEOUT, () => this.runtime.on(Runtime.PERIPHERAL_SCAN_TIMEOUT, () =>
this.emit(Runtime.PERIPHERAL_SCAN_TIMEOUT) this.emit(Runtime.PERIPHERAL_SCAN_TIMEOUT)