question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inputs are not updated before actions

See original GitHub issue

example

The input data of connected nodes are not updated until after the onAction event. I have even tried moving the trigger to after I set the output data of the node.

Lachee Console Node

//Show value inside the debug console
function LConsole()
{
	//this.mode = LiteGraph.ON_EVENT;
	this.size = [80,30];
	this.addInput("log", LiteGraph.EVENT);
    this.addInput("cnt", 0, { label: "Message"});
    this.cnt = "";
}

LConsole.title = "Lachee Console";
LConsole.desc = "Show value inside the console";

LConsole.prototype.onAction = function(action, param)
{
    console.log("Action:", action );
    console.log("Params:", param );
    console.log("Self:", this );
    console.log("CNT: " + this.cnt );
    console.log("A: ", this.getInputData(0));
    console.log("B: ", this.getInputData(1));	
    
	this.inputs[1].label = this.cnt;
}

LConsole.prototype.onExecute = function()
{
    if (this.inputs[1])
        this.cnt = this.getInputData(1);
}

LConsole.prototype.onDrawBackground = function(ctx)
{
	//show the current value
	this.inputs[1].label = this.cnt;
}

LiteGraph.registerNodeType("basic/lconsole", LConsole );

On Message Node

function OnMessageEvent()
{
	this.addOutput("on_message", LiteGraph.EVENT);
	this.addOutput("author", 0);
    this.addOutput("content", 0);
    this.author = "Lachee";
    this.content = ".ping";
    this.triggered = false;
    this.clonable = false;
    this.resizable = false;
    this.color = LGraphCanvas.node_colors.purple.color;
    this.bgcolor = LGraphCanvas.node_colors.purple.bgcolor;
}

OnMessageEvent.title = "On Message";
OnMessageEvent.desc = "Occurs when a message is sent";

OnMessageEvent.on_color = "#AAA";
OnMessageEvent.off_color = "#222";


OnMessageEvent.prototype.onStart = function() {}

OnMessageEvent.prototype.onDrawBackground = function()
{
	this.boxcolor = this.triggered ? OnMessageEvent.on_color : OnMessageEvent.off_color;
	this.triggered = false;
}

OnMessageEvent.prototype.onExecute = function()
{
	var dt = this.graph.elapsed_time * 1000; //in ms
	var trigger = message_queue.length != 0;

    if (trigger)
    {
        console.log("TRIGGER");
        this.setOutputData(1, "Lachee");
        this.setOutputData(2, message_queue[0]);
        this.trigger("on_message", message_queue[0]);
        message_queue = [];
        this.triggered = true;
    }
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
DiegoBMcommented, Mar 10, 2021

Was this ever implemented? It would be interesting to be able to execute backwards the inputs of the event nodes, so that they can get fresh values without needing to run the entire tree. From what I understand, that’s what Blueprints does. In the end most javascript applications will be more event-based than frame-based

1reaction
jagenjocommented, Apr 24, 2019

I will research on the topic this week, I could create a function that executes from Node triggering the event to the node receiving the event.

Ask me about it in one week

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Input is not updating value attribute on change
For some reason the input tags in my form are not updating the value attribute when they are changed view the actual element...
Read more >
Text Input not updating via Action tool - Alteryx Community
Solved: I am trying to set up a Text box to update Text Input tool value in first line and column, the action...
Read more >
Input Field Not Updating after calling .replace()
I have a regex and a replace method. But the invalid characters only get removed after I enter a valid one. I could...
Read more >
<input type="text"> - HTML: HyperText Markup Language | MDN
The value attribute is a string that contains the current value of the text entered into the text field. You can retrieve this...
Read more >
How schedule actions work - AWS Elemental MediaLive
The channel stops ingesting the current input and starts ingesting the specified input. The input must already be attached to the channel. Before...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found