Skip to content

Commit

Permalink
Allow callbacks to be unset #181
Browse files Browse the repository at this point in the history
Also-by: Piotr Kuczynski <piotr.kuczynski@gmail.com>
  • Loading branch information
Ian Craggs committed Jun 4, 2019
1 parent b53e982 commit a1d0c16
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/paho-mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ function onMessageArrived(message) {
"onConnected":{
get: function() { return client.onConnected; },
set: function(newOnConnected) {
if (typeof newOnConnected === "function")
if (newOnConnected === null || typeof newOnConnected === "function")
client.onConnected = newOnConnected;
else
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnected, "onConnected"]));
Expand All @@ -1838,7 +1838,7 @@ function onMessageArrived(message) {
"onConnectionLost":{
get: function() { return client.onConnectionLost; },
set: function(newOnConnectionLost) {
if (typeof newOnConnectionLost === "function")
if (newOnConnectionLost === null || typeof newOnConnectionLost === "function")
client.onConnectionLost = newOnConnectionLost;
else
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnectionLost, "onConnectionLost"]));
Expand All @@ -1847,7 +1847,7 @@ function onMessageArrived(message) {
"onMessageDelivered":{
get: function() { return client.onMessageDelivered; },
set: function(newOnMessageDelivered) {
if (typeof newOnMessageDelivered === "function")
if (newOnMessageDelivered === null || typeof newOnMessageDelivered === "function")
client.onMessageDelivered = newOnMessageDelivered;
else
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageDelivered, "onMessageDelivered"]));
Expand All @@ -1856,7 +1856,7 @@ function onMessageArrived(message) {
"onMessageArrived":{
get: function() { return client.onMessageArrived; },
set: function(newOnMessageArrived) {
if (typeof newOnMessageArrived === "function")
if (newOnMessageArrived === null || typeof newOnMessageArrived === "function")
client.onMessageArrived = newOnMessageArrived;
else
throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageArrived, "onMessageArrived"]));
Expand All @@ -1865,7 +1865,7 @@ function onMessageArrived(message) {
"trace":{
get: function() { return client.traceFunction; },
set: function(trace) {
if(typeof trace === "function"){
if(trace === null || typeof trace === "function"){
client.traceFunction = trace;
}else{
throw new Error(format(ERROR.INVALID_TYPE, [typeof trace, "onTrace"]));
Expand Down

0 comments on commit a1d0c16

Please sign in to comment.