AppFlowy/frontend/app_flowy/lib/startup/launcher.dart

41 lines
884 B
Dart
Raw Normal View History

2021-06-19 15:41:19 +00:00
import 'package:app_flowy/startup/startup.dart';
import 'package:get_it/get_it.dart';
class LaunchContext {
GetIt getIt;
IntegrationEnv env;
LaunchContext(this.getIt, this.env);
}
enum LaunchTaskType {
dataProcessing,
appLauncher,
}
/// The interface of an app launch task, which will trigger
/// some nonresident indispensable task in app launching task.
abstract class LaunchTask {
LaunchTaskType get type => LaunchTaskType.dataProcessing;
2021-07-12 15:27:58 +00:00
Future<void> initialize(LaunchContext context);
2021-06-19 15:41:19 +00:00
}
class AppLauncher {
List<LaunchTask> tasks;
IntegrationEnv env;
GetIt getIt;
AppLauncher(this.env, this.getIt) : tasks = List.from([]);
void addTask(LaunchTask task) {
tasks.add(task);
}
2021-07-12 15:27:58 +00:00
void launch() async {
2021-06-19 15:41:19 +00:00
final context = LaunchContext(getIt, env);
for (var task in tasks) {
2021-07-12 15:27:58 +00:00
await task.initialize(context);
2021-06-19 15:41:19 +00:00
}
}
}
//test git hooks