Skip to content

Commit

Permalink
added no propagate event handler example
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-higgins committed Mar 9, 2024
1 parent 9b204d6 commit 1427bfc
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.fluxtion.example.reference.execution;

import com.fluxtion.compiler.Fluxtion;
import com.fluxtion.runtime.annotations.OnEventHandler;
import com.fluxtion.runtime.annotations.OnTrigger;

public class NoPropagateEventHandler {

public static class MyNode {
@OnEventHandler
public boolean handleStringEvent(String stringToProcess) {
System.out.println("MyNode::handleStringEvent received:" + stringToProcess);
return true;
}

@OnEventHandler(propagate = false)
public boolean handleIntEvent(int intToProcess) {
System.out.println("MyNode::handleIntEvent received:" + intToProcess);
return true;
}
}


public static class Child {
private final MyNode myNode;

public Child(MyNode myNode) {
this.myNode = myNode;
}

@OnTrigger
public boolean triggered() {
System.out.println("Child:triggered");
return true;
}
}

public static void main(String[] args) {
var processor = Fluxtion.interpret(new Child(new MyNode()));
processor.init();
processor.onEvent("test");
System.out.println();
processor.onEvent(200);
}
}

0 comments on commit 1427bfc

Please sign in to comment.