mqttjs / mqtt-elements

Polymer elements for MQTT
http://mqttjs.github.io/mqtt-elements/
MIT License
27 stars 6 forks source link

When creating a mqtt-connection with an auto mqtt-publish the message should be send when the connection is established #13

Closed sandro-k closed 9 years ago

sandro-k commented 9 years ago
<mqtt-connection
    url="ws://iot.eclipse.org:80/ws"
    auto>
  <mqtt-publish topic="foo/bar" payload="this is easy" auto></mqtt-publish>
</mqtt-connection>

Minimal working example dose not automatically publish to "foo/bar" when the the connection is established. Probably _propertiesChanged is not run when this._parentConnection is set via its parent.

mcollina commented 9 years ago

You can just call client.publish() even before a 'connect' event in MQTT.js, the publish will be queued up and sent as the connection is established (for the first time).

sandro-k commented 9 years ago

I know.. but the mqtt-publish element will not have any knowledge about which client it belongs too until set by the parent mqtt-connection . Even the mqtt-connection might get the client injected via its mqtt-connection#client property and then will delegate it down to the mqtt-publish element. Anyway just wanted to document this and create a fix and test for it.