Update di example

This commit is contained in:
Roman Mogilatov 2016-03-30 11:45:41 +03:00
parent 08b00d71d4
commit 4e00a70834
3 changed files with 4 additions and 11 deletions

View File

@ -8,13 +8,10 @@ class Components(catalogs.DeclarativeCatalog):
"""Components catalog."""
service = providers.Factory(Service)
""":type: providers.Factory -> Service"""
client = providers.Factory(Client,
service=service)
""":type: providers.Factory -> Client"""
if __name__ == '__main__':
# Application creates Client's instance using its provider
client = Components.client() # equivalent of Client(service=Service())
client = Components.client() # Application creates Client's instance

View File

@ -14,5 +14,4 @@ class Client(object):
if __name__ == '__main__':
# Application just creates Client's instance
client = Client()
client = Client() # Application creates Client's instance

View File

@ -14,8 +14,5 @@ class Client(object):
if __name__ == '__main__':
# Application creates Service instance
service = Service()
# and inject Service instance into the Client
client = Client(service)
service = Service() # Application creates Service instance
client = Client(service) # and inject Service instance into the Client