Skip to content

Autoload Decorator

This file defines the Autoload decorator, which allows you to specify the initialization order of modules when using the autoloader in the @sodacore/core library. By setting a priority, you can control the order in which modules are initialized, which is useful when modules have dependencies on each other.


Features

  • Priority Control: Assigns a priority to a module for autoloading order.
  • Metadata Storage: Stores the priority as metadata using the Utils.setMeta helper.

Usage

typescript
import Autoload from './decorator/autoload';

@Autoload(10)
export class MyModule {
	// Module implementation
}
  • Modules with lower priority values are initialized before those with higher values.
  • The default priority is 50 if not specified.

API

Autoload(priority: number): ClassDecorator

  • priority: The priority value for the module's autoload order (lower means earlier initialization).
  • Returns: A class decorator that sets the order metadata for autowiring.

Notes

  • Use this decorator when your module depends on the initialization of other modules.
  • The autoloader uses the stored priority to sort modules before initializing them.

Released under the Apache-2.0 License.