diff --git a/DOCS.md b/DOCS.md index eed7c91..12f528e 100644 --- a/DOCS.md +++ b/DOCS.md @@ -76,8 +76,8 @@ Emits when a LPF2 Hub device is found. * [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle) ⇒ Promise * [.connect()](#Hub+connect) ⇒ Promise * [.disconnect()](#Hub+disconnect) - * [.subscribe(port, [mode])](#Hub+subscribe) - * [.unsubscribe(port)](#Hub+unsubscribe) + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * ["button" (button, state)](#BoostHub+event_button) * ["distance" (port, distance)](#BoostHub+event_distance) * ["color" (port, color)](#BoostHub+event_color) @@ -140,10 +140,11 @@ Disconnect the Hub. **Kind**: instance method of [BoostHub](#BoostHub) -### boostHub.subscribe(port, [mode]) +### boostHub.subscribe(port, [mode]) ⇒ Promise Subscribe to sensor notifications on a given port. **Kind**: instance method of [BoostHub](#BoostHub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | | --- | --- | --- | @@ -152,10 +153,11 @@ Subscribe to sensor notifications on a given port. -### boostHub.unsubscribe(port) +### boostHub.unsubscribe(port) ⇒ Promise Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [BoostHub](#BoostHub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | | --- | --- | @@ -234,8 +236,8 @@ Emits when a rotation sensor is activated. * [.setMotorSpeed(port, speed)](#WeDo2Hub+setMotorSpeed) ⇒ Promise * [.connect()](#Hub+connect) ⇒ Promise * [.disconnect()](#Hub+disconnect) - * [.subscribe(port, [mode])](#Hub+subscribe) - * [.unsubscribe(port)](#Hub+unsubscribe) + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * ["button" (button, state)](#WeDo2Hub+event_button) * ["distance" (port, distance)](#WeDo2Hub+event_distance) * ["color" (port, color)](#WeDo2Hub+event_color) @@ -297,10 +299,11 @@ Disconnect the Hub. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) -### weDo2Hub.subscribe(port, [mode]) +### weDo2Hub.subscribe(port, [mode]) ⇒ Promise Subscribe to sensor notifications on a given port. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | | --- | --- | --- | @@ -309,10 +312,11 @@ Subscribe to sensor notifications on a given port. -### weDo2Hub.unsubscribe(port) +### weDo2Hub.unsubscribe(port) ⇒ Promise Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | | --- | --- | @@ -388,8 +392,8 @@ Emits when a rotation sensor is activated. * [Hub](#Hub) ⇐ EventEmitter * [.connect()](#Hub+connect) ⇒ Promise * [.disconnect()](#Hub+disconnect) - * [.subscribe(port, [mode])](#Hub+subscribe) - * [.unsubscribe(port)](#Hub+unsubscribe) + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise @@ -406,10 +410,11 @@ Disconnect the Hub. **Kind**: instance method of [Hub](#Hub) -### hub.subscribe(port, [mode]) +### hub.subscribe(port, [mode]) ⇒ Promise Subscribe to sensor notifications on a given port. **Kind**: instance method of [Hub](#Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | | --- | --- | --- | @@ -418,10 +423,11 @@ Subscribe to sensor notifications on a given port. -### hub.unsubscribe(port) +### hub.unsubscribe(port) ⇒ Promise Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [Hub](#Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | | --- | --- | diff --git a/README.md b/README.md index 044e40b..6a9bcc6 100644 --- a/README.md +++ b/README.md @@ -116,8 +116,8 @@ Emits when a LPF2 Hub device is found. * [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle) ⇒ Promise * [.connect()](#Hub+connect) ⇒ Promise * [.disconnect()](#Hub+disconnect) - * [.subscribe(port, [mode])](#Hub+subscribe) - * [.unsubscribe(port)](#Hub+unsubscribe) + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * ["button" (button, state)](#BoostHub+event_button) * ["distance" (port, distance)](#BoostHub+event_distance) * ["color" (port, color)](#BoostHub+event_color) @@ -180,10 +180,11 @@ Disconnect the Hub. **Kind**: instance method of [BoostHub](#BoostHub) -### boostHub.subscribe(port, [mode]) +### boostHub.subscribe(port, [mode]) ⇒ Promise Subscribe to sensor notifications on a given port. **Kind**: instance method of [BoostHub](#BoostHub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | | --- | --- | --- | @@ -192,10 +193,11 @@ Subscribe to sensor notifications on a given port. -### boostHub.unsubscribe(port) +### boostHub.unsubscribe(port) ⇒ Promise Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [BoostHub](#BoostHub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | | --- | --- | @@ -274,8 +276,8 @@ Emits when a rotation sensor is activated. * [.setMotorSpeed(port, speed)](#WeDo2Hub+setMotorSpeed) ⇒ Promise * [.connect()](#Hub+connect) ⇒ Promise * [.disconnect()](#Hub+disconnect) - * [.subscribe(port, [mode])](#Hub+subscribe) - * [.unsubscribe(port)](#Hub+unsubscribe) + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * ["button" (button, state)](#WeDo2Hub+event_button) * ["distance" (port, distance)](#WeDo2Hub+event_distance) * ["color" (port, color)](#WeDo2Hub+event_color) @@ -337,10 +339,11 @@ Disconnect the Hub. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) -### weDo2Hub.subscribe(port, [mode]) +### weDo2Hub.subscribe(port, [mode]) ⇒ Promise Subscribe to sensor notifications on a given port. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | | --- | --- | --- | @@ -349,10 +352,11 @@ Subscribe to sensor notifications on a given port. -### weDo2Hub.unsubscribe(port) +### weDo2Hub.unsubscribe(port) ⇒ Promise Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | | --- | --- | @@ -428,8 +432,8 @@ Emits when a rotation sensor is activated. * [Hub](#Hub) ⇐ EventEmitter * [.connect()](#Hub+connect) ⇒ Promise * [.disconnect()](#Hub+disconnect) - * [.subscribe(port, [mode])](#Hub+subscribe) - * [.unsubscribe(port)](#Hub+unsubscribe) + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise @@ -446,10 +450,11 @@ Disconnect the Hub. **Kind**: instance method of [Hub](#Hub) -### hub.subscribe(port, [mode]) +### hub.subscribe(port, [mode]) ⇒ Promise Subscribe to sensor notifications on a given port. **Kind**: instance method of [Hub](#Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | | --- | --- | --- | @@ -458,10 +463,11 @@ Subscribe to sensor notifications on a given port. -### hub.unsubscribe(port) +### hub.unsubscribe(port) ⇒ Promise Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [Hub](#Hub) +**Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | | --- | --- | diff --git a/hub.ts b/hub.ts index 10f9c99..50c866b 100644 --- a/hub.ts +++ b/hub.ts @@ -121,6 +121,7 @@ export class Hub extends EventEmitter { * @method Hub#subscribe * @param {string} port * @param {number} [mode] The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. + * @returns {Promise} Resolved upon successful issuance of command. */ public subscribe (port: string, mode?: number) { return new Promise((resolve, reject) => { @@ -138,6 +139,7 @@ export class Hub extends EventEmitter { * Unsubscribe to sensor notifications on a given port. * @method Hub#unsubscribe * @param {string} port + * @returns {Promise} Resolved upon successful issuance of command. */ public unsubscribe (port: string) { return new Promise((resolve, reject) => {