eclipse-paho / eclipse-paho/paho.mqtt.javascript

subscribe only takes a single topic, yet returns an array

Open
#18 0 comments 0 reactions 1 assignee Claimed by @jpwsutton View on GitHub
enhancement
Dominant language
JavaScript
Stars
1.2k
Forks
466
PR merge metrics
No merged PRs in 30d

Description

migrated from Bugzilla [#440767](https://bugs.eclipse.org/bugs/show_bug.cgi?id=440767)
status UNCONFIRMED severity _normal_ in component _MQTT-JS_ for _1.1_
Reported in version _1.0_ on platform _All_
Assigned to: Tang Zi Han

On 2014-07-30 08:57:30 -0400, Karl Palsson wrote:

> MQTT Spec allows sending multiple topics to subscribe in a single message, and replies with a list of granted QoS.
>
> The current API only allows subscribing to a single topic, yet still returns an array, (with only one entry)
>
> Ideally, both of these would work:
>
> client.subscribe(topicA, qosA, {existing options blob (if we must) for callback definition})
> which would invoke callbacks with just a single granted qos field, not an array,
>
> and also...
>
> client.subscribe([[topicA, qosA],[topicB,qosB],....], ...) which would return an array of qos's.
>
> I don't actually personally even _need_ a way to subscribe to multiple topics in one call, but the only time I would _ever_ want an array of granted qos back is if I had actually subscribed to multiple topics.

On 2014-08-26 01:49:43 -0400, Tang Zi Han wrote:

> Currently the subscribe API allows a single topic and return an array of grantedQos.
> The first fix step is to return a single grantedQos to match one topic.

On 2014-09-08 05:57:23 -0400, Al Stockdill-Mander wrote:

> Changing the return type in the callback is an API change, so not something I would be keen to see. Perhaps it would be better to allow subscriptions to multiple topics in a subscribe call.

On 2014-09-08 06:09:11 -0400, Karl Palsson wrote:

> If the API is confusing and inconsistent, surely there must be a path to change it. Backwards compatible is only useful if the old way is good.

On 2015-01-08 02:10:31 -0500, Tang Zi Han wrote:

> (In reply to Tang Zi Han from comment # 1)
>
> > Currently the subscribe API allows a single topic and return an array of
> > grantedQos.
> > The first fix step is to return a single grantedQos to match one topic.
> > Commit change to develop branch: https://git.eclipse.org/r/#/c/39165/
>
> Currently the subscribe api :
> this.subscribe = function (filter, subscribeOptions)
> the qos is a number and include in subscribeOptions.
> It is not very clear to change the api to
> subscribe ([topic1,topic2],{qos:[1,1],onsuccess:function(){},onfailure:function(){}....})
>
> In current version, it will be a big api change if changing the api to
> client.subscribe([[topicA, qosA],[topicB,qosB],....], callback).
>
> It's better to add a new api to subscribe multiple topic in the following version.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.