Skip to content

Commit 647ba92

Browse files
authored
feat: add InitializableDependency interface (#6)
* Add InitializableDependency interface * Set presolveUsing as required * Deprecate Presolve dependency class
1 parent b25da00 commit 647ba92

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
abstract class InitializableDependency {
2+
/// Handles Asynchronously initialization.
3+
Future<void> init();
4+
}

lib/src/code_generation/locator/stacked_locator_annotations.dart

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,36 @@ class FactoryParam {
118118
const factoryParam = FactoryParam._();
119119

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

125126
const Presolve({
126127
Type? classType,
127128
Type? asType,
128-
this.presolveUsing,
129+
required this.presolveUsing,
129130
Set<String>? environments,
130131
String? instanceName,
131132
}) : super(
132-
instanceName: instanceName,
133-
classType: classType,
134-
asType: asType,
135-
environments: environments);
133+
instanceName: instanceName,
134+
classType: classType,
135+
asType: asType,
136+
environments: environments,
137+
);
138+
}
139+
140+
/// Registers the type passed in to be presolved using the function passed in
141+
class InitializableSingleton extends DependencyRegistration {
142+
const InitializableSingleton({
143+
Type? classType,
144+
Type? asType,
145+
Set<String>? environments,
146+
String? instanceName,
147+
}) : super(
148+
instanceName: instanceName,
149+
classType: classType,
150+
asType: asType,
151+
environments: environments,
152+
);
136153
}

lib/stacked_shared.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ library stacked_shared;
66
export 'src/backward_compatibility/flutter_v2_compatibility.dart';
77
export 'src/code_generation/environment_filter.dart';
88
export 'src/code_generation/forms/stacked_form_annotations.dart';
9+
export 'src/code_generation/locator/initializable_dependency.dart';
910
export 'src/code_generation/locator/stacked_locator.dart';
1011
export 'src/code_generation/locator/stacked_locator_annotations.dart';
1112
export 'src/code_generation/logger/stacked_logger_annotations.dart';

0 commit comments

Comments
 (0)