Skip to content

ParameterFactory & dynamic singleton #338

@Vincz

Description

@Vincz

Hi!
I'm trying to use the ParameterFactory to create dynamic services.
At first I didn't read the documentation paragraph:

Finally, if you define a scope keep in mind that the first argument passed will be used to create the dependency and that dependency will be cached. Since the cached object will be returned from now on any arguments passed in later requests will be ignored until the factory or scope is reset.

My use case would be to have a cached version based on the parameter (the parameter is a Hashable), so when I request a service with the given parameter, it resolves the proper one based on the parameter and not the latest cached one. So it dynamically create services based on this parameter.
Is it something doable and is their a proper way to do it with Factory?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions