Skip to content

Commit 905a314

Browse files
authored
Merge branch 'main' into test/setup-event-db-environment
2 parents 36f45cb + 9533da9 commit 905a314

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

catalyst_voices/apps/voices/lib/configs/bootstrap.dart

+14-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Future<void> _doBootstrapAndRun(BootstrapWidgetBuilder builder) async {
7474
await _runApp(app);
7575
}
7676

77+
@visibleForTesting
7778
GoRouter buildAppRouter({
7879
String? initialLocation,
7980
}) {
@@ -85,6 +86,18 @@ GoRouter buildAppRouter({
8586
);
8687
}
8788

89+
@visibleForTesting
90+
Future<void> registerDependencies() async {
91+
if (!Dependencies.instance.isInitialized) {
92+
await Dependencies.instance.init();
93+
}
94+
}
95+
96+
@visibleForTesting
97+
Future<void> restartDependencies() async {
98+
await Dependencies.instance.reset;
99+
}
100+
88101
/// Initializes the application before it can be run. Should setup all
89102
/// the things which are necessary before the actual app is run,
90103
/// either via [runApp] or injected into a test environment during
@@ -102,7 +115,7 @@ Future<BootstrapArgs> bootstrap({
102115
GoRouter.optionURLReflectsImperativeAPIs = true;
103116
setPathUrlStrategy();
104117

105-
await Dependencies.instance.init();
118+
await registerDependencies();
106119

107120
// Key derivation needs to be initialized before it can be used
108121
await CatalystKeyDerivation.init();

catalyst_voices/apps/voices/lib/dependency/dependencies.dart

+13
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,26 @@ import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
1010
final class Dependencies extends DependencyProvider {
1111
static final Dependencies instance = Dependencies._();
1212

13+
bool _isInitialized = false;
14+
1315
Dependencies._();
1416

1517
Future<void> init() async {
1618
DependencyProvider.instance = this;
1719
_registerServices();
1820
_registerRepositories();
1921
_registerBlocsWithDependencies();
22+
23+
_isInitialized = true;
24+
}
25+
26+
bool get isInitialized => _isInitialized;
27+
28+
@override
29+
Future<void> get reset {
30+
return super.reset.whenComplete(() {
31+
_isInitialized = false;
32+
});
2033
}
2134

2235
void _registerBlocsWithDependencies() {

0 commit comments

Comments
 (0)