Skip to content

Allow to set event handlers to null #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
node_modules
.npm
target
Expand Down
10 changes: 5 additions & 5 deletions src/paho-mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,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 @@ -1830,7 +1830,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 @@ -1839,7 +1839,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 @@ -1848,7 +1848,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 @@ -1857,7 +1857,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