heusalagroup / fi.hg.core

Our enterprise library for TypeScript
MIT License
2 stars 2 forks source link

Autowired annotation #96

Open thejhh opened 1 year ago

thejhh commented 1 year ago

@Autowired Annotation: By employing this annotation, parameters, properties, and setters will be automatically wired based on their types. This will simplify dependency injection and improve code modularity.

Example

export class NorAgentApp {

    @useAutowired()
    public static async run (
        @autowired('args')
        args: readonly string[],
        @autowired('stateService')
        stateService ?: AgentStateService,
        @autowired('parsedArgs')
        parsedArgs ?: ParsedCommandArgumentObject,
        @autowired('destroyService')
        destroyService ?: DestroyService,
    ): Promise<CommandExitStatus> {
        console.log('Hello World');
    }
}

TODO

For further insights and references, please refer to the following resources:

thejhh commented 1 year ago

This is not perfect but step forward.