-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added no propagate event handler example
- Loading branch information
1 parent
9b204d6
commit 1427bfc
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...ution/src/main/java/com/fluxtion/example/reference/execution/NoPropagateEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |