Trait that adds one-time initialization lifecycle hooks to any class. More...
#include <Malena/Engine/App/Lifecycle.h>
Public Member Functions | |
| virtual | ~Lifecycle ()=default |
| virtual void | onInit () |
| Called once after construction, before the first frame. | |
| virtual void | onReady () |
Called once after onInit(), when all components are registered. | |
Trait that adds one-time initialization lifecycle hooks to any class.
Lifecycle provides two virtual hooks that bracket the startup phase of an object. Both have empty default implementations — override only what you need.
| Hook | When it fires |
|---|---|
onInit() | Once, immediately after construction, before the first frame |
onReady() | Once, after onInit(), once all components are registered |
The distinction between the two hooks mirrors the pattern established by frameworks such as Angular and iOS UIKit:
onInit() is the place to perform setup that does not depend on other components being fully registered (load resources, configure properties).onReady() is the place to wire logic that requires all sibling objects to already exist (cross-component references, initial state calculations).Lifecycle is independent of SceneLifecycle. Opt into both if your class is a scene that also needs one-time initialization hooks:
Definition at line 72 of file Lifecycle.h.
|
virtualdefault |
|
inlinevirtual |
Called once after construction, before the first frame.
Override to perform initial setup — configure component properties, load resources, and register objects with the framework. At this point no other sibling components are guaranteed to be fully registered.
Definition at line 82 of file Lifecycle.h.
|
inlinevirtual |
Called once after onInit(), when all components are registered.
Override to wire logic that depends on other components already existing — event callbacks, cross-component bindings, or derived initial state.
Definition at line 90 of file Lifecycle.h.