mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
added documentations
This commit is contained in:
@@ -11,6 +11,30 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/// An annotation to specify that a method or class provides a new instance
|
||||||
|
/// each time it is requested.
|
||||||
|
///
|
||||||
|
/// This is typically used to indicate that the annotated binding should
|
||||||
|
/// not be a singleton and a new object is created for every injection.
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// ```dart
|
||||||
|
/// @module()
|
||||||
|
/// abstract class AppModule extends Module {
|
||||||
|
/// @instance()
|
||||||
|
/// Foo foo() => Foo();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// This will generate:
|
||||||
|
/// ```dart
|
||||||
|
/// final class $AppModule extends AppModule {
|
||||||
|
/// @override
|
||||||
|
/// void builder(Scope currentScope) {
|
||||||
|
/// bind<Foo>().toInstance(() => foo());
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
// ignore: camel_case_types
|
// ignore: camel_case_types
|
||||||
final class instance {
|
final class instance {
|
||||||
const instance();
|
const instance();
|
||||||
|
|||||||
@@ -11,6 +11,22 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/// An annotation to indicate that a parameter is to be injected with run-time provided arguments.
|
||||||
|
///
|
||||||
|
/// Use this annotation to mark a method parameter that should receive arguments
|
||||||
|
/// passed during the resolution of a dependency (for example, through the
|
||||||
|
/// `.withParams(...)` method in the generated code).
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// ```dart
|
||||||
|
/// @provide()
|
||||||
|
/// String greet(@params() dynamic params) => 'Hello $params';
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// This will generate:
|
||||||
|
/// ```dart
|
||||||
|
/// bind<String>().toProvideWithParams((args) => greet(args));
|
||||||
|
/// ```
|
||||||
// ignore: camel_case_types
|
// ignore: camel_case_types
|
||||||
final class params {
|
final class params {
|
||||||
const params();
|
const params();
|
||||||
|
|||||||
@@ -11,6 +11,31 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/// An annotation to indicate that a method provides a dependency to the module.
|
||||||
|
///
|
||||||
|
/// This annotation is typically used in conjunction with dependency injection,
|
||||||
|
/// marking methods whose return value should be registered as a provider.
|
||||||
|
/// The annotated method can optionally declare dependencies as parameters,
|
||||||
|
/// which will be resolved and injected automatically.
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// ```dart
|
||||||
|
/// @module()
|
||||||
|
/// abstract class AppModule extends Module {
|
||||||
|
/// @provide()
|
||||||
|
/// Foo foo(Bar bar) => Foo(bar);
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// This will generate:
|
||||||
|
/// ```dart
|
||||||
|
/// final class $AppModule extends AppModule {
|
||||||
|
/// @override
|
||||||
|
/// void builder(Scope currentScope) {
|
||||||
|
/// bind<Foo>().toProvide(() => foo(currentScope.resolve<Bar>()));
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
// ignore: camel_case_types
|
// ignore: camel_case_types
|
||||||
final class provide {
|
final class provide {
|
||||||
const provide();
|
const provide();
|
||||||
|
|||||||
Reference in New Issue
Block a user