lagom icon indicating copy to clipboard operation
lagom copied to clipboard

Investigate creating container with immutable contents restriction

Open meadsteve opened this issue 3 years ago • 0 comments

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))

meadsteve avatar Nov 22 '21 09:11 meadsteve