lagom
lagom copied to clipboard
Investigate creating container with immutable contents restriction
Currently the container can contain mutable state if it contains singletons. In most usage this would not be an issue and is in fact the required behaviour. However from a design point of view it would be nice to have an inner immutable core that only has immutable definitions and then a second layer with the mutable singletons defined.
Something like this:
core_deps = ImmutableContainer()
core_deps[SomeService] = lamba: SomeService()
core_deps[SomeService] = Singleton(Whatever) # Raises an error
#... later
deps = core_deps.clone()
deps[SomeService] = Singleton(lambda: c.resolve_from_parent(SomeService))