mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-27 07:04:12 +00:00
docs(annotations): unify and improve English DartDoc for all DI annotations
- Updated all annotation files with complete English DartDoc, field/class/method usage, practical code samples - Unified documentation style for @inject, @injectable, @instance, @singleton, @named, @scope, @params, @provide, @module - Removed Russian comments for clarity and consistency - Improved discoverability and IDE/autocomplete experience for CherryPick DI users - No functional or API changes; documentation/dev experience only
This commit is contained in:
@@ -11,58 +11,39 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/// ENGLISH:
|
||||
/// Annotation to specify that a new instance should be provided on each request.
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// Marks a provider method or class to always create a new instance (factory) in CherryPick DI.
|
||||
///
|
||||
/// 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).
|
||||
/// Use `@instance()` to annotate methods or classes in your DI module/class
|
||||
/// when you want a new object to be created on every injection (no singleton caching).
|
||||
/// The default DI lifecycle is instance/factory unless otherwise specified.
|
||||
///
|
||||
/// Example:
|
||||
/// ### Example (in a module method)
|
||||
/// ```dart
|
||||
/// import 'package:cherrypick_annotations/cherrypick_annotations.dart';
|
||||
///
|
||||
/// @module()
|
||||
/// abstract class AppModule extends Module {
|
||||
/// abstract class FeatureModule {
|
||||
/// @instance()
|
||||
/// Foo foo() => Foo();
|
||||
/// MyService provideService() => MyService();
|
||||
///
|
||||
/// @singleton()
|
||||
/// Logger provideLogger() => Logger();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This will generate:
|
||||
/// ### Example (on a class, with @injectable)
|
||||
/// ```dart
|
||||
/// final class $AppModule extends AppModule {
|
||||
/// @override
|
||||
/// void builder(Scope currentScope) {
|
||||
/// bind<Foo>().toInstance(() => foo());
|
||||
/// }
|
||||
/// @injectable()
|
||||
/// @instance()
|
||||
/// class MyFactoryClass {
|
||||
/// // ...
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// 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
|
||||
/// See also: [@singleton]
|
||||
@experimental
|
||||
final class instance {
|
||||
const instance();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user