1 | | | import 'dart:async'; |
2 | | |
|
3 | | | import 'worker_request.dart'; |
4 | | |
|
5 | | | typedef WorkerInitializer = FutureOr<WorkerService> Function( |
6 | | | WorkerRequest startRequest); |
7 | | |
|
8 | | | typedef CommandHandler = FutureOr Function(WorkerRequest req); |
9 | | |
|
10 | | | typedef SquadronCallback = void Function(); |
11 | | |
|
12 | | | /// Base class for a worker service. |
13 | | | abstract class WorkerService { |
14 | | | /// Map of command handlers. Upon reception of a [WorkerRequest], the platform worker will dispatch the request |
15 | | | /// to the [CommandHandler] mathing the value of [WorkerRequest.command]. |
16 | | | Map<int, CommandHandler> get operations; |
17 | | |
|
18 | | | /// Empty command handlers map. |
19 | | 3 | static final Map<int, CommandHandler> noOperations = |
20 | | 2 | Map<int, CommandHandler>.unmodifiable(const {}); |
21 | | | } |