Package org.ngengine.components
Interface ComponentInitializer
- All Known Implementing Classes:
AppComponentInitializer
public interface ComponentInitializer
An interface to initializing and cleaning up components in the component manager. This is used to perform
any necessary setup or teardown for a component when it is added or removed.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canInitialize
(ComponentManager mng, Component fragment) Check if the component can be initialized by this initializer.void
cleanup
(ComponentManager mng, Component fragment) Cleanup the component in the given component manager.int
initialize
(ComponentManager mng, Component fragment, Runnable markReady) Initialize the component in the given component manager.
-
Method Details
-
initialize
Initialize the component in the given component manager. This method is called when the component is added to the component manager.- Parameters:
mng
- the component managerfragment
- the component to initializemarkReady
- a runnable that should be called when the initialization is complete- Returns:
- how many times the markReady callback is expected to be called to mark the complete initialization.
-
cleanup
Cleanup the component in the given component manager. This method is called when the component is removed from the component manager.- Parameters:
mng
- the component managerfragment
- the component to cleanup
-
canInitialize
Check if the component can be initialized by this initializer. This is used to determine if the component is compatible with this initializer and can be initialized without issues. If the component is not compatible, it will not be initialized and the component manager will call the next available initializer in the chain.- Parameters:
mng
- the component managerfragment
- the component to check- Returns:
- true if the component can be initialized, false otherwise
-