Skip to content

Commit dd7fc4c

Browse files
authored
Allow to set event handlers to null
1 parent 413f729 commit dd7fc4c

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
@@ -1809,7 +1809,7 @@ function onMessageArrived(message) {
18091809
"onConnected":{
18101810
get: function() { return client.onConnected; },
18111811
set: function(newOnConnected) {
1812-
if (typeof newOnConnected === "function")
1812+
if (newOnConnected === null || typeof newOnConnected === "function")
18131813
client.onConnected = newOnConnected;
18141814
else
18151815
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnected, "onConnected"]));
@@ -1830,7 +1830,7 @@ function onMessageArrived(message) {
18301830
"onConnectionLost":{
18311831
get: function() { return client.onConnectionLost; },
18321832
set: function(newOnConnectionLost) {
1833-
if (typeof newOnConnectionLost === "function")
1833+
if (newOnConnectionLost === null || typeof newOnConnectionLost === "function")
18341834
client.onConnectionLost = newOnConnectionLost;
18351835
else
18361836
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnectionLost, "onConnectionLost"]));
@@ -1839,7 +1839,7 @@ function onMessageArrived(message) {
18391839
"onMessageDelivered":{
18401840
get: function() { return client.onMessageDelivered; },
18411841
set: function(newOnMessageDelivered) {
1842-
if (typeof newOnMessageDelivered === "function")
1842+
if (newOnMessageDelivered === null || typeof newOnMessageDelivered === "function")
18431843
client.onMessageDelivered = newOnMessageDelivered;
18441844
else
18451845
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageDelivered, "onMessageDelivered"]));
@@ -1848,7 +1848,7 @@ function onMessageArrived(message) {
18481848
"onMessageArrived":{
18491849
get: function() { return client.onMessageArrived; },
18501850
set: function(newOnMessageArrived) {
1851-
if (typeof newOnMessageArrived === "function")
1851+
if (newOnMessageArrived === null || typeof newOnMessageArrived === "function")
18521852
client.onMessageArrived = newOnMessageArrived;
18531853
else
18541854
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageArrived, "onMessageArrived"]));
@@ -1857,7 +1857,7 @@ function onMessageArrived(message) {
18571857
"trace":{
18581858
get: function() { return client.traceFunction; },
18591859
set: function(trace) {
1860-
if(typeof trace === "function"){
1860+
if (trace === null || typeof trace === "function"){
18611861
client.traceFunction = trace;
18621862
}else{
18631863
throw new Error(format(ERROR.INVALID_TYPE, [typeof trace, "onTrace"]));

0 commit comments

Comments
 (0)