Skip to content

Commit a1d0c16

Browse files
author
Ian Craggs
committed
Allow callbacks to be unset #181
Also-by: Piotr Kuczynski <[email protected]>
1 parent b53e982 commit a1d0c16

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/paho-mqtt.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ function onMessageArrived(message) {
18171817
"onConnected":{
18181818
get: function() { return client.onConnected; },
18191819
set: function(newOnConnected) {
1820-
if (typeof newOnConnected === "function")
1820+
if (newOnConnected === null || typeof newOnConnected === "function")
18211821
client.onConnected = newOnConnected;
18221822
else
18231823
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnected, "onConnected"]));
@@ -1838,7 +1838,7 @@ function onMessageArrived(message) {
18381838
"onConnectionLost":{
18391839
get: function() { return client.onConnectionLost; },
18401840
set: function(newOnConnectionLost) {
1841-
if (typeof newOnConnectionLost === "function")
1841+
if (newOnConnectionLost === null || typeof newOnConnectionLost === "function")
18421842
client.onConnectionLost = newOnConnectionLost;
18431843
else
18441844
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnectionLost, "onConnectionLost"]));
@@ -1847,7 +1847,7 @@ function onMessageArrived(message) {
18471847
"onMessageDelivered":{
18481848
get: function() { return client.onMessageDelivered; },
18491849
set: function(newOnMessageDelivered) {
1850-
if (typeof newOnMessageDelivered === "function")
1850+
if (newOnMessageDelivered === null || typeof newOnMessageDelivered === "function")
18511851
client.onMessageDelivered = newOnMessageDelivered;
18521852
else
18531853
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageDelivered, "onMessageDelivered"]));
@@ -1856,7 +1856,7 @@ function onMessageArrived(message) {
18561856
"onMessageArrived":{
18571857
get: function() { return client.onMessageArrived; },
18581858
set: function(newOnMessageArrived) {
1859-
if (typeof newOnMessageArrived === "function")
1859+
if (newOnMessageArrived === null || typeof newOnMessageArrived === "function")
18601860
client.onMessageArrived = newOnMessageArrived;
18611861
else
18621862
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageArrived, "onMessageArrived"]));
@@ -1865,7 +1865,7 @@ function onMessageArrived(message) {
18651865
"trace":{
18661866
get: function() { return client.traceFunction; },
18671867
set: function(trace) {
1868-
if(typeof trace === "function"){
1868+
if(trace === null || typeof trace === "function"){
18691869
client.traceFunction = trace;
18701870
}else{
18711871
throw new Error(format(ERROR.INVALID_TYPE, [typeof trace, "onTrace"]));

0 commit comments

Comments
 (0)