mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 13:47:24 +00:00
doc: update documentations
This commit is contained in:
@@ -11,11 +11,12 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/// An annotation to specify that a method or class provides a new instance
|
||||
/// each time it is requested.
|
||||
/// ENGLISH:
|
||||
/// Annotation to specify that a new instance should be provided on each request.
|
||||
///
|
||||
/// This is typically used to indicate that the annotated binding should
|
||||
/// not be a singleton and a new object is created for every injection.
|
||||
/// Use the `@instance()` annotation for methods or classes in your DI module
|
||||
/// to declare that the DI container must create a new object every time
|
||||
/// the dependency is injected (i.e., no singleton behavior).
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
@@ -35,6 +36,32 @@
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// RUSSIAN (Русский):
|
||||
/// Аннотация для создания нового экземпляра при каждом запросе.
|
||||
///
|
||||
/// Используйте `@instance()` для методов или классов в DI-модуле,
|
||||
/// чтобы указать, что контейнер внедрения зависимостей должен создавать
|
||||
/// новый объект при каждом обращении к зависимости (то есть, не синглтон).
|
||||
///
|
||||
/// Пример:
|
||||
/// ```dart
|
||||
/// @module()
|
||||
/// abstract class AppModule extends Module {
|
||||
/// @instance()
|
||||
/// Foo foo() => Foo();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Будет сгенерирован следующий код:
|
||||
/// ```dart
|
||||
/// final class $AppModule extends AppModule {
|
||||
/// @override
|
||||
/// void builder(Scope currentScope) {
|
||||
/// bind<Foo>().toInstance(() => foo());
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
// ignore: camel_case_types
|
||||
final class instance {
|
||||
const instance();
|
||||
|
||||
Reference in New Issue
Block a user