Interface Fragment

All Known Subinterfaces:
AppFragment, AssetLoadingFragment, AsyncAssetLoadingFragment, GuiViewPortFragment, InputHandlerFragment, LogicFragment, MainViewPortFragment, RenderFragment
All Known Implementing Classes:
NWindowManagerComponent, PlayerManagerComponent

public interface Fragment
Fragments are interfaces that define specialized capabilities for components in the engine.

The fragment system provides a composition-based approach to building app components, allowing developers to opt-in to specific engine functionalities without complex inheritance hierarchies or linking code. Each fragment represents a specific capability or integration point with the engine.

Common fragment types include:

When a component implements a fragment interface, the ComponentManager automatically detects this capability and connects the component to the appropriate subsystem, eliminating the need for manual registration or boilerplate code.

Multiple fragments can be implemented by a single component, enabling a flexible mix of capabilities through interface composition rather than inheritance.

Method Execution Order

Fragments follow a specific execution sequence:
  1. Initialization Phase: All receiveXXX methods (like receiveViewPort, receiveInputManager) are called when the component is first initialized.
  2. Loading Phase: All load methods (like loadAssetsAsync) are called right before the component would be enabled. The component remains in pending state until all load methods complete.
  3. Enable Phase: The Component.onEnable(ComponentManager, Runner, DataStoreProvider, boolean, Object) method is called when the component is enabled, after the initialization and loading phases are complete.
  4. Update Phase: All update methods (like updateViewPort, update) are called every frame for each enabled component.
  5. Disable Phase: The Component.onDisable(ComponentManager, Runner, DataStoreProvider) method is called when the component is disabled, either explicitly, due to a dependency change or due it being detached.
See Also: