Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding callback to thingShadow.register #83

Closed

Conversation

Torsph
Copy link

@Torsph Torsph commented Aug 18, 2016

  • Update the thing register function with a completion callback
  • Add new test for the different states (ignoreDelta and persistentSubscribe)
  • Updated README.md to reflect the new changes

Fixes issue #80 if I understood the aws and mqtt implementation correct. The new code waits for the mqtt lib to invoke the callback on ignoreDeltas and persistentSubscribe topics. When the mqtt lib has invoked both callbacks, will the register function invoke the register callback.

Maybe need for some more test cases, but please review and provide with feedback :)

- Update the thing register function with a completion callback
- Add new test for the different states (ignoreDelta and persistentSubscribe)
- Updated README.md to reflect the new changes
@Torsph Torsph force-pushed the add_callback_to_thingshadow_register branch from d8b1007 to caeccf7 Compare August 19, 2016 05:41
pending: false
pending: false,
pendingDeltaSubscribe: true,
pendingPersistentSubscribe: true
Copy link

@rongsaws rongsaws Aug 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better not to treat delta ad other shadow topic subscriptions separately. One flag should be enough to tell if the shadow is ready to take actions. If you like, you could modify _handleSubscriptions() so both delta and other topic subscriptions can be handled in one call; the extra benefit of it is one less MQTT message transmission.

In the same vein, callback should also be invoked only once to be deterministic and avoid user confusion.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I was thinking about that. I will make the needed changes :)

@Torsph Torsph force-pushed the add_callback_to_thingshadow_register branch from 0d18560 to 8c183c7 Compare August 22, 2016 15:46
@Torsph
Copy link
Author

Torsph commented Aug 22, 2016

Will clean up the branch if it's accepted. How do you like it? rebase into one commit or something else?

@@ -526,6 +572,8 @@ function ThingShadowsClient(deviceOptions, thingShadowOptions) {

this.unregister = function(thingName) {
if (thingShadows.hasOwnProperty(thingName)) {
var topicsObject = [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use topicObjects to be consistent with your prior definition; and perhaps topicSpecs or toipcDefinitions is more readable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

@rongsaws
Copy link

Hey, thanks again for working on this.

Your second commit looks good overall. If you don't mind, I could pull it in to our internal pipeline and have a reviewed by 2nd pair of eyes after making some minor adjustments? We could then have it released after that.

@Torsph
Copy link
Author

Torsph commented Aug 23, 2016

Do you want me to fix the small issues before you pull it into the internal pipe?

@rongsaws
Copy link

Certainly if you are up for it:)

@Torsph
Copy link
Author

Torsph commented Aug 23, 2016

Sure! Happy to help :)


it("should trigger error when a subscription fails", function () {

var stubTriggerError = sinon.stub(mockMQTTClient, 'triggerError', function(){return true;});
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't used sinon that much before, so don't know if I did it the correct way :)

@Torsph
Copy link
Author

Torsph commented Aug 23, 2016

  • Changed the named to topicSpecs
  • Moved the pending assignment
  • The callback returns the error message and the topics that failed.
  • Updated the test with sinon stub. (Haven't used sinon that much so it may be wrong, but it works :))

Hope that will do the work. Please just do all the changes needed in your internal review :)

@Torsph
Copy link
Author

Torsph commented Sep 12, 2016

Hi!

Do you have any update this PR? :)

@jimisataws
Copy link

Hi Torsph,

Thanks for your contributions. These changes are included in our next release cycle and currently going through the internal pipeline.

Thanks
Jimi

@liuszeng
Copy link
Contributor

liuszeng commented Nov 1, 2016

Addressed in release v1.0.13.

@liuszeng liuszeng closed this Nov 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants