We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Using TypeScript, reading user properties requires something like this (MQTT client):
client.on('message', function(topic, message, packet) { const pckt: IPublishPacket = Object.assign(packet); if (pckt.properties && pckt.properties.userProperties) { const userProperties: {[index: string]: string} = Object.assign(pckt.properties.userProperties); console.log(userProperties['test']); } });
It would be better if the userProperties were changed from being {object} to being {[index: string]: string}.
It would also be better if the on message callback (in MQTT) required an IPublishPacket rather than the more generic Packet.
Changing both these would allow type assignments to be removed and the TypeScript code could be changed to:
client.on('message', function(topic, message, packet) { if (packet.properties && packet.properties.userProperties) { console.log(packet.properties.userProperties['test']); } });
Linked to mqttjs/MQTT.js#1248
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Using TypeScript, reading user properties requires something like this (MQTT client):
It would be better if the userProperties were changed from being {object} to being {[index: string]: string}.
It would also be better if the on message callback (in MQTT) required an IPublishPacket rather than the more generic Packet.
Changing both these would allow type assignments to be removed and the TypeScript code could be changed to:
Linked to mqttjs/MQTT.js#1248
The text was updated successfully, but these errors were encountered: