<commit_before>module.exports = function(RED) {
    function AllVariableChangesNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        node.variable = config.variable;

		function changeListener(changedVar, value) {
			var msg = { payload:value, variable: changedVar.name};
			node.send(msg);
        }
		
		RED.settings.pimaticFramework.variableManager.on('variableValueChanged', changeListener);
		
		node.on("close", function(done) {
            RED.settings.pimaticFramework.variableManager.removeListener("variableValueChanged", changeListener)
			done();
        });
    }
    RED.nodes.registerType("allvariables in",AllVariableChangesNode);
	
    function VariableChangedNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        node.variable = config.variable;
		
		if (RED.settings.pimaticFramework.variableManager.isVariableDefined(node.variable)) {
			node.status({fill:"green",shape:"ring",text:"ok"});
		} else {
			node.status({fill:"red",shape:"ring",text:"variable not found"});
		}
		
		function changeListener(changedVar, value) {
			if(changedVar.name == node.variable) {
				var msg = { payload:value, variable: node.variable};
				node.send(msg);
			}
        }
<commit_msg>Only emit a message when the value actually changed<commit_after>module.exports = function(RED) {
    function AllVariableChangesNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        node.variable = config.variable;

		function changeListener(changedVar, value) {
			var msg = { payload:value, variable: changedVar.name};
			node.send(msg);
        }
		
		RED.settings.pimaticFramework.variableManager.on('variableValueChanged', changeListener);
		
		node.on("close", function(done) {
            RED.settings.pimaticFramework.variableManager.removeListener("variableValueChanged", changeListener)
			done();
        });
    }
    RED.nodes.registerType("allvariables in",AllVariableChangesNode);
	
    function VariableChangedNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        node.variable = config.variable;
		
		if (RED.settings.pimaticFramework.variableManager.isVariableDefined(node.variable)) {
			node.status({fill:"green",shape:"ring",text:"ok"});
		} else {
			node.status({fill:"red",shape:"ring",text:"variable not found"});
		}
		
		function changeListener(changedVar, value) {
			if(changedVar.name == node.variable) {
                                var context = node.context();
                                if (context.get('value') != value) {
                                       context.set('value', value);
				       var msg = { payload:value, variable: node.variable};
				       node.send(msg);
                                }
			}
        }

{'fraction_non_alphanumeric': 0.1283327408460718, 'fraction_numerical': 0.0, 'mean_word_length': 2.9356643356643355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3986932', 'n_tokens_mistral': 863, 'n_tokens_neox': 758, 'n_words': 124}