| 
									
										
										
										
											2021-06-19 23:41:19 +08: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 23:27:58 +08:00
										 |  |  |   Future<void> initialize(LaunchContext context); | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08: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 23:27:58 +08:00
										 |  |  |   void launch() async { | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |     final context = LaunchContext(getIt, env); | 
					
						
							|  |  |  |     for (var task in tasks) { | 
					
						
							| 
									
										
										
										
											2021-07-12 23:27:58 +08:00
										 |  |  |       await task.initialize(context); | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | //test git hooks
 |