onEvent abstract method

void onEvent(
  1. GraphEvent event
)

Called when a graph event occurs.

Use pattern matching to handle events of interest:

void onEvent(GraphEvent event) {
  switch (event) {
    case NodeAdded(:final node):
      // Handle node added
    case NodeMoved(:final node, :final previousPosition):
      // Handle node moved
    case BatchStarted(:final reason):
      // Start accumulating events
    case BatchEnded():
      // Finalize batch
    default:
      // Ignore other events
  }
}

Implementation

void onEvent(GraphEvent event);