aws / aws-iot-device-sdk-js

SDK for connecting to AWS IoT from a device using JavaScript/Node.js
Apache License 2.0
964 stars 384 forks source link

awsIot.thingShadow#register() options parameter is not independently optional #106

Closed aztecrex closed 7 years ago

aztecrex commented 7 years ago

The documentation for the API shows a signature with optional options and callback parameters. The example shows the function invoked with only two parameters, the shadow name and the callback.

However, the options parameter appears to be required if a callback is supplied. If called the way shown in the example, the callback is never called. This can be fixed in the code by checking if the second argument is a function. Or it can be fixed in the documentation by enclosing the final two formal parameters in another square bracket and modifying the example to include an empty hash for the second argument.

chaurah commented 7 years ago

Hi @aztecrex, Thank you for pointing this out. We will take a call on what the correct fix should be in this case and include it in the next release. Please do let us know if you have any further suggestions. Thank you for using AWS IoT.

Rahul

psiphi75 commented 7 years ago

The same applies for many other functions, such as awsIot.thingShadow#publish, awsIot.thingShadow#subscribe, etc.

fengsongAWS commented 7 years ago

Hi @psiphi75 ,

The subscribe and publish APIs should not be affected because it invokes the under layer mqtt API directly. The options and callback are independently optional. We will fix the thingShadow.register() API in the future release.

Thanks

fengsongAWS commented 7 years ago

Fixed in v2.0.0