Initialization
Simply annotate any singleton object with @Init and Nova will load the class during
the specified initialization stage.
Dispatcher
You can also define an initialization dispatcher: SYNC (default) to perform the initialization synchronously with all
other initializables, or ASYNC to perform the initialization asynchronously, in parallel with other async initializables.
@Init(
stage = InitStage.POST_WORLD,
dispatcher = Dispatcher.ASYNC
)
object Example {
@InitFun
private fun init() {
// ...
}
}
Initialization Dependencies
If the pre-defined initialization stages are not enough for you, you can also configure which classes that should be
initialized before (runAfter) or after (runBefore) your class:
Example initializable class with dependencies
@Init(
stage = InitStage.PRE_PACK,
runAfter = [ClassA::class], // This class will be initialized after ClassA
runBefore = [ClassB::class] // This class will be initialized before ClassB
)
object Example
Functions
If your class is annotated with @Init, you can also annotate your functions with @InitFun
and @DisableFun. There, you can also configure initialization dependencies and a dispatcher.
For @InitFun.
@InitFun: Specify one or more functions that should be called during initialization.@DisableFunSpecify one or more functions that should be called when your addon is disabled.