wireup icon indicating copy to clipboard operation
wireup copied to clipboard

Introduce functional deps

Open maldoinc opened this issue 1 year ago • 0 comments

They can ask for dependencies as usual and return a function that will perform the task.

@container.functional
def greeter_factory(translator_service: TranslatorService, other_service ...) -> Callable...
    def greeter(name: str, locale: str = 'en_GB') -> str:
        return ...

    return greeter

@container.autowire
def target(greeter: Annotated[Callable..., Wire(fn=greeter_factory))
    ...

maldoinc avatar Dec 21 '23 23:12 maldoinc