Skip to content

Commit

Permalink
added some binding examples
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-higgins committed Mar 17, 2024
1 parent 63432be commit b014a57
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.fluxtion.example.reference;

import com.fluxtion.compiler.Fluxtion;
import com.fluxtion.compiler.builder.dataflow.DataFlow;
import com.fluxtion.runtime.annotations.OnEventHandler;

public class CombineFunctionalAndImperative {

public static String toUpper(String incoming){
return incoming.toUpperCase();
}

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

public static void main(String[] args) {
var processor = Fluxtion.interpret(cfg -> {
DataFlow.subscribe(String.class)
.console("FUNCTIONAL input: '{}'")
.map(CombineFunctionalAndImperative::toUpper)
.console("FUNCTIONAL transformed: '{}'");

cfg.addNode(new MyNode());
});

processor.init();
processor.onEvent("hello world");
}
}

0 comments on commit b014a57

Please sign in to comment.