mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-23 01:56:58 +03:00
Update providers index page
This commit is contained in:
parent
dd2ded7321
commit
c2426d2a09
|
@ -1,3 +1,5 @@
|
||||||
|
.. _create-provider:
|
||||||
|
|
||||||
Creating a custom providers
|
Creating a custom providers
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ Providers help to assemble the objects. They create objects and inject the depen
|
||||||
|
|
||||||
Each provider is a callable. You call the provider like a function when you need to create an
|
Each provider is a callable. You call the provider like a function when you need to create an
|
||||||
object. Provider retrieves the underlying dependencies and inject them into the created object.
|
object. Provider retrieves the underlying dependencies and inject them into the created object.
|
||||||
It causes the cascade effect that helps to assemble object graphs.
|
It causes the cascade effect that helps to assemble object graphs. See ``Factory``, ``Singleton``,
|
||||||
|
``Callable`` and other provider docs below.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
|
@ -23,10 +24,13 @@ It causes the cascade effect that helps to assemble object graphs.
|
||||||
│
|
│
|
||||||
└──> provider6()
|
└──> provider6()
|
||||||
|
|
||||||
Another providers feature is an overriding. Any of the providers can be overridden by another
|
Another providers feature is an overriding. You can override any provider by another provider.
|
||||||
provider. When provider is overridden it calls to the overriding provider instead of providing
|
This helps in testing. This also helps in overriding API clients with stubs for the development
|
||||||
the object by its own. This helps in testing. This also helps in overriding API clients with
|
or staging environment. See the example at :ref:`provider-overriding`.
|
||||||
stubs for the development or staging environment. See the example at :ref:`provider-overriding`.
|
|
||||||
|
If you need to inject not the whole object but the parts see :ref:`provided-instance`.
|
||||||
|
|
||||||
|
To create a new provider see :ref:`create-provider`.
|
||||||
|
|
||||||
Providers module API docs - :py:mod:`dependency_injector.providers`
|
Providers module API docs - :py:mod:`dependency_injector.providers`
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. _provided-instance:
|
||||||
|
|
||||||
Injecting provided object attributes, items, or call its methods
|
Injecting provided object attributes, items, or call its methods
|
||||||
================================================================
|
================================================================
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user