From f6365b0c667aaa4900b6a906278b83abb3846d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Fri, 20 May 2016 10:45:49 -0400 Subject: [PATCH] Cleaner topic slection --- hardware/physical-web/physical-web.js | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/hardware/physical-web/physical-web.js b/hardware/physical-web/physical-web.js index d7d45bb2..937bcca9 100644 --- a/hardware/physical-web/physical-web.js +++ b/hardware/physical-web/physical-web.js @@ -187,33 +187,15 @@ module.exports = function(RED) { node.duplicates = n.duplicates; function onFound(beacon) { - var topic_data; - if (node.topic !== "") { - topic_data = node.topic; - } else { - topic_data = 'found'; - } - node.send({topic: topic_data, payload: beacon}); + node.send({topic: node.topic || 'found', payload: beacon}); } function onUpdated(beacon) { - var topic_data; - if (node.topic !== "") { - topic_data = node.topic; - } else { - topic_data = 'updated'; - } - node.send({topic: topic_data, payload: beacon}); + node.send({topic: node.topic || 'updated', payload: beacon}); } function onLost(beacon) { - var topic_data; - if (node.topic !== "") { - topic_data = node.topic; - } else { - topic_data = 'lost'; - } - node.send({topic: topic_data, payload: beacon}); + node.send({topic: node.topic || 'lost', payload: beacon}); } EddystoneBeaconScanner.on('found', onFound);