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.""" """Components catalog."""
service = providers.Factory(Service) service = providers.Factory(Service)
""":type: providers.Factory -> Service"""
client = providers.Factory(Client, client = providers.Factory(Client,
service=service) service=service)
""":type: providers.Factory -> Client"""
if __name__ == '__main__': if __name__ == '__main__':
# Application creates Client's instance using its provider client = Components.client() # Application creates Client's instance
client = Components.client() # equivalent of Client(service=Service())

View File

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

View File

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