I'm developing a simple Java based MCU simulation for the Pic16F84 µC. This simulator is divided into two parts:
- The µC simulation (Memory, CPU, ALU, etc.)
- The Graphical User Interface (JavaFX) for displaying memory content etc.
How could I connect the simulator with the UI in a reactive way? I want to develop the µC simulation as JavaFX independent unit. This means I don't want to use JavaFX related property classes as class fields inside of the simulator's classes.
For example let's say I've the following controller class bound to a FXML view:
public class SimulatorController implements Initializable {
@FXML private Label memoryContent;
private Pic16F84Simulator simulator;
...
public SimulatorController() {
simulator.getMemory().addPropertyChangeListener(event -> {
memoryContent.setText((String) event.getValue());
}
}
}
I'm using PropertyChangeListener
s for updating reactive. Of course most of the time the listener logic isn't that simple. So the code base grows very fast.
Is there a more elegant way connecting a JavaFX UI with a UI independent back-end class? With independent I mean I could extract the simulator implementation without any remaining JavaFX dependencies.