mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 09:57:37 +03:00 
			
		
		
		
	Updating singleton examples
This commit is contained in:
		
							parent
							
								
									2690d9b9d4
								
							
						
					
					
						commit
						996fc4ecbf
					
				| 
						 | 
					@ -21,7 +21,6 @@ Example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        """Example class UserService."""
 | 
					        """Example class UserService."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Singleton provider creates new instance of specified class on first call and
 | 
					    # Singleton provider creates new instance of specified class on first call and
 | 
				
			||||||
    # returns same instance on every next call.
 | 
					    # returns same instance on every next call.
 | 
				
			||||||
    users_service_provider = Singleton(UserService)
 | 
					    users_service_provider = Singleton(UserService)
 | 
				
			||||||
| 
						 | 
					@ -35,7 +34,6 @@ Example:
 | 
				
			||||||
    assert isinstance(user_service1, UserService)
 | 
					    assert isinstance(user_service1, UserService)
 | 
				
			||||||
    assert isinstance(user_service2, UserService)
 | 
					    assert isinstance(user_service2, UserService)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
Singleton providers and injections
 | 
					Singleton providers and injections
 | 
				
			||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 | 
					~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +82,6 @@ Example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        """Example class UserService."""
 | 
					        """Example class UserService."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Users service singleton provider:
 | 
					    # Users service singleton provider:
 | 
				
			||||||
    users_service_provider = Singleton(UserService)
 | 
					    users_service_provider = Singleton(UserService)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -105,4 +102,3 @@ Example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Making some asserts:
 | 
					    # Making some asserts:
 | 
				
			||||||
    assert user_service3 is not user_service1
 | 
					    assert user_service3 is not user_service1
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,6 @@ class UserService(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    """Example class UserService."""
 | 
					    """Example class UserService."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Singleton provider creates new instance of specified class on first call and
 | 
					# Singleton provider creates new instance of specified class on first call and
 | 
				
			||||||
# returns same instance on every next call.
 | 
					# returns same instance on every next call.
 | 
				
			||||||
users_service_provider = Singleton(UserService)
 | 
					users_service_provider = Singleton(UserService)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,6 @@ class UserService(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    """Example class UserService."""
 | 
					    """Example class UserService."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Users service singleton provider:
 | 
					# Users service singleton provider:
 | 
				
			||||||
users_service_provider = Singleton(UserService)
 | 
					users_service_provider = Singleton(UserService)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user