Removed all callback apis

This commit is contained in:
Nathan Kunicki 2018-06-22 12:05:13 +01:00
parent fdd4bb8114
commit 92248caca5
4 changed files with 37 additions and 37 deletions

30
DOCS.md
View File

@ -19,7 +19,7 @@
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
* [.scan()](#LPF2+scan)
* [.scan()](#LPF2+scan)
* [.stop()](#LPF2+stop)
* [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
* [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [<code>Array.&lt;Hub&gt;</code>](#Hub)
* ["discover" (hub)](#LPF2+event_discover)
@ -30,9 +30,9 @@
Begin scanning for LPF2 Hub devices.
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
<a name="LPF2+scan"></a>
<a name="LPF2+stop"></a>
### lpF2.scan()
### lpF2.stop()
Stop scanning for LPF2 Hub devices.
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
@ -145,10 +145,10 @@ Subscribe to sensor notifications on a given port.
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| port | <code>string</code> | | |
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
| Param | Type | Description |
| --- | --- | --- |
| port | <code>string</code> | |
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
<a name="Hub+unsubscribe"></a>
@ -302,10 +302,10 @@ Subscribe to sensor notifications on a given port.
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| port | <code>string</code> | | |
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
| Param | Type | Description |
| --- | --- | --- |
| port | <code>string</code> | |
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
<a name="Hub+unsubscribe"></a>
@ -411,10 +411,10 @@ Subscribe to sensor notifications on a given port.
**Kind**: instance method of [<code>Hub</code>](#Hub)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| port | <code>string</code> | | |
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
| Param | Type | Description |
| --- | --- | --- |
| port | <code>string</code> | |
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
<a name="Hub+unsubscribe"></a>

View File

@ -59,7 +59,7 @@ Examples are available in the "examples" directory.
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
* [.scan()](#LPF2+scan)
* [.scan()](#LPF2+scan)
* [.stop()](#LPF2+stop)
* [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
* [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [<code>Array.&lt;Hub&gt;</code>](#Hub)
* ["discover" (hub)](#LPF2+event_discover)
@ -70,9 +70,9 @@ Examples are available in the "examples" directory.
Begin scanning for LPF2 Hub devices.
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
<a name="LPF2+scan"></a>
<a name="LPF2+stop"></a>
### lpF2.scan()
### lpF2.stop()
Stop scanning for LPF2 Hub devices.
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
@ -185,10 +185,10 @@ Subscribe to sensor notifications on a given port.
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| port | <code>string</code> | | |
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
| Param | Type | Description |
| --- | --- | --- |
| port | <code>string</code> | |
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
<a name="Hub+unsubscribe"></a>
@ -342,10 +342,10 @@ Subscribe to sensor notifications on a given port.
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| port | <code>string</code> | | |
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
| Param | Type | Description |
| --- | --- | --- |
| port | <code>string</code> | |
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
<a name="Hub+unsubscribe"></a>
@ -451,10 +451,10 @@ Subscribe to sensor notifications on a given port.
**Kind**: instance method of [<code>Hub</code>](#Hub)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| port | <code>string</code> | | |
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
| Param | Type | Description |
| --- | --- | --- |
| port | <code>string</code> | |
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
<a name="Hub+unsubscribe"></a>

12
hub.ts
View File

@ -120,14 +120,14 @@ export class Hub extends EventEmitter {
* Subscribe to sensor notifications on a given port.
* @method Hub#subscribe
* @param {string} port
* @param {number|boolean} [mode=false] - The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.
* @param {number} [mode] The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.
*/
public subscribe (port: string, mode: number | boolean = false, callback?: () => void) {
public subscribe (port: string, mode?: number) {
let newMode = 0x00;
if (!mode) {
if (mode && !(typeof mode === "number")) {
newMode = this._getModeForDeviceType(this._ports[port].type);
}
this._activatePortDevice(this._ports[port].value, this._ports[port].type, newMode, 0x00, callback);
this._activatePortDevice(this._ports[port].value, this._ports[port].type, newMode, 0x00);
}
/**
@ -135,9 +135,9 @@ export class Hub extends EventEmitter {
* @method Hub#unsubscribe
* @param {string} port
*/
public unsubscribe (port: string, callback?: () => void) {
public unsubscribe (port: string) {
const mode = this._getModeForDeviceType(this._ports[port].type);
this._deactivatePortDevice(this._ports[port].value, this._ports[port].type, mode, 0x00, callback);
this._deactivatePortDevice(this._ports[port].value, this._ports[port].type, mode, 0x00);
}

View File

@ -101,7 +101,7 @@ export class LPF2 extends EventEmitter {
/**
* Stop scanning for LPF2 Hub devices.
* @method LPF2#scan
* @method LPF2#stop
*/
public stop () {
wantScan = false;