diff --git a/.changeset/curvy-apes-run.md b/.changeset/curvy-apes-run.md new file mode 100644 index 0000000..d9181ac --- /dev/null +++ b/.changeset/curvy-apes-run.md @@ -0,0 +1,5 @@ +--- +'vue-paho-mqtt': patch +--- + +fixed an issue that disabled changing the default mqtt options diff --git a/src/pahoMqttPlugin/config/client.ts b/src/pahoMqttPlugin/config/client.ts index 36b1ed3..9aa554f 100644 --- a/src/pahoMqttPlugin/config/client.ts +++ b/src/pahoMqttPlugin/config/client.ts @@ -1,26 +1,26 @@ import { Client } from 'paho-mqtt'; -import { getMqttOptions } from './options'; +import { getMqttOptions, setMqttOptions } from './options'; import { MqttOptions } from '../types'; -const MqttOptions = getMqttOptions(); +const mqttOptions = getMqttOptions(); let client = new Client( - MqttOptions.host, - MqttOptions.port, - MqttOptions.clientId, + mqttOptions.host, + mqttOptions.port, + mqttOptions.clientId, ); export const getClient = () => client; export const createClient = ( options: MqttOptions = { - host: MqttOptions.host, - port: MqttOptions.port, - clientId: MqttOptions.clientId, + host: getMqttOptions().host, + port: getMqttOptions().port, + clientId: getMqttOptions().clientId, }, ) => { client = new Client( - (MqttOptions.host = options.host), - (MqttOptions.port = options.port), - (MqttOptions.clientId = options.clientId), + (mqttOptions.host = options.host), + (mqttOptions.port = options.port), + (mqttOptions.clientId = options.clientId), ); return client; };