Skip to content

Singleton Provider

The Singleton provider creates and provides single object. It memorizes the first created object and returns it on the rest of the calls.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from uzi import Container, providers

class Service:
    ...

container = Container()

container.singleton(Service)
# or manually create the provider
container[Service] = providers.Singleton(Service)
Back to top