Skip to content

Conversation

@jskrzypek
Copy link
Contributor

The changelog for v4.2.0 lists "Add optional support for promises on all endpoints."

The documentation for what returns promises is basically non-existent, but I received an error when trying to do this:

pubnub.setState({ channels: ['my_channel'], state: { 'isTyping': 'true' } }).then((res) => { console.log(res); });

The error I get is "EXCEPTION: Cannot read property 'then' of undefined", because pubnub.setState() doesn't return a promise like the hereNow(), whereNow(), and getState() endpoints.

After digging into the source a bit, I realized that the reason the function is not returning the promise is that the call to the endpoint built by the util is not actually being returned by _subsctiptionManager.adaptStateChange(), here, which should instead be this:

return this._setStateEndpoint({ state, channels, channelGroups }, callback);

I also added an integration test to stateSetting.test.js to ensure that the promises succeed.

@MaxPresman
Copy link
Contributor

merged. a gulp build was required to generate the library files but it's all covered! Thank you for the PR!

@MaxPresman MaxPresman closed this Oct 31, 2016
@MaxPresman
Copy link
Contributor

7044017

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.

2 participants