Skip to content

Commit

Permalink
feat: Add InitializableDependency interface (#5)
Browse files Browse the repository at this point in the history
* Add InitializableDependency interface

* Set presolveUsing as required

* Deprecate Presolve dependency class
  • Loading branch information
ferrarafer committed Jun 7, 2023
1 parent b25da00 commit fd9e597
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/src/code_generation/locator/initializable_dependency.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
abstract class InitializableDependency {
/// Handles Asynchronously initialization.
Future<void> init();
}
29 changes: 23 additions & 6 deletions lib/src/code_generation/locator/stacked_locator_annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,36 @@ class FactoryParam {
const factoryParam = FactoryParam._();

/// Registers the type passed in to be presolved using the function passed in
@Deprecated('Use InitializableSingleton instead.')
class Presolve extends DependencyRegistration {
/// The static instance Future function to use for resolving the type registered
final Future Function()? presolveUsing;
final Future Function() presolveUsing;

const Presolve({
Type? classType,
Type? asType,
this.presolveUsing,
required this.presolveUsing,
Set<String>? environments,
String? instanceName,
}) : super(
instanceName: instanceName,
classType: classType,
asType: asType,
environments: environments);
instanceName: instanceName,
classType: classType,
asType: asType,
environments: environments,
);
}

/// Registers the type passed in to be presolved using the function passed in
class InitializableSingleton extends DependencyRegistration {
const InitializableSingleton({
Type? classType,
Type? asType,
Set<String>? environments,
String? instanceName,
}) : super(
instanceName: instanceName,
classType: classType,
asType: asType,
environments: environments,
);
}
1 change: 1 addition & 0 deletions lib/stacked_shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ library stacked_shared;
export 'src/backward_compatibility/flutter_v2_compatibility.dart';
export 'src/code_generation/environment_filter.dart';
export 'src/code_generation/forms/stacked_form_annotations.dart';
export 'src/code_generation/locator/initializable_dependency.dart';
export 'src/code_generation/locator/stacked_locator.dart';
export 'src/code_generation/locator/stacked_locator_annotations.dart';
export 'src/code_generation/logger/stacked_logger_annotations.dart';
Expand Down

0 comments on commit fd9e597

Please sign in to comment.