| 1 | | | import 'dart:async'; |
| 2 | | | |
| 3 | | | import 'worker/worker.dart'; |
| 4 | | | |
| 5 | | | /// Extend this class or implement this interface in your worker service if it needs |
| 6 | | | /// to take action when the worker thread is started or stopped. |
| 7 | | | mixin ServiceInstaller { |
| 8 | | | /// Squadron will call this method as part of the worker thread initialization. |
| 9 | | | /// It will be called just after the service instance has been constructed. The |
| 10 | | | /// future returned by [Worker.start] will not complete before this method completes |
| 11 | | | /// whether synchronously or asynchronously. If this method throws, the future |
| 12 | | | /// returned by [Worker.start] will complete with an error and the service will not |
| 13 | | | /// be available. |
| 14 | | 2 | FutureOr<void> install() {} |
| 15 | | | |
| 16 | | | /// Squadron will call this method as part of the worker thread shutdown process. |
| 17 | | | /// It will be called just before effectively closing the platform channel. If |
| 18 | | | /// this method throws, the exception will not bubble up to the parent thread. |
| 19 | | | /// Also, [Worker.stop] does not wait for this method to complete. |
| 20 | | 2 | FutureOr<void> uninstall() {} |
| 21 | | | } |