From 2ff4dff832042617a3653eceefb6fe95a546f3a4 Mon Sep 17 00:00:00 2001 From: rapmue Date: Tue, 3 Oct 2017 19:28:44 +0200 Subject: [PATCH] [aws-iot-device-sdk] combine multiple signatures (#20229) * [aws-iot-device-sdk] combine multiple signatures In order to use different signatures, I suggest to combine multiple functions to one, with the different parameter types as a list. * added a test Added a test for thingshadow subscribe. The test only covers the error which happened before when using a subscription with a string. --- types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts | 2 ++ types/aws-iot-device-sdk/index.d.ts | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts b/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts index 10eeed099d..bcb407c352 100644 --- a/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts +++ b/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts @@ -68,6 +68,8 @@ const thingShadows = new awsIot.thingShadow({ (err: Error, failedTopics: mqtt.Granted[]) => { } ); + thingShadows.subscribe("topic", {}, (error: any, granted: mqtt.Granted) => {}); + thingShadows.on("connect", function() { console.log("connected to AWS IoT"); }); diff --git a/types/aws-iot-device-sdk/index.d.ts b/types/aws-iot-device-sdk/index.d.ts index b165089f82..8d01f279eb 100644 --- a/types/aws-iot-device-sdk/index.d.ts +++ b/types/aws-iot-device-sdk/index.d.ts @@ -333,8 +333,7 @@ export class thingShadow extends NodeJS.EventEmitter { * @param options * @param callback */ - publish(topic: string, message: Buffer, options?: mqtt.ClientPublishOptions, callback?: Function): mqtt.Client; - publish(topic: string, message: string, options?: mqtt.ClientPublishOptions, callback?: Function): mqtt.Client; + publish(topic: string, message: Buffer | string, options?: mqtt.ClientPublishOptions, callback?: Function): mqtt.Client; /** * Subscribe to a topic or topics @@ -342,9 +341,7 @@ export class thingShadow extends NodeJS.EventEmitter { * @param the options to subscribe with * @param callback fired on suback */ - subscribe(topic: string, options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client; - subscribe(topic: string[], options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client; - subscribe(topic: mqtt.Topic, options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client; + subscribe(topic: string | string[] | mqtt.Topic, options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client; /** * Unsubscribe from a topic or topics @@ -353,8 +350,7 @@ export class thingShadow extends NodeJS.EventEmitter { * @param options * @param callback fired on unsuback */ - unsubscribe(topic: string, options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client; - unsubscribe(topic: string[], options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client; + unsubscribe(topic: string | string[], options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client; /** * end - close connection