1 | | | import '../pool/worker_pool.dart'; |
2 | | | import 'target_platform.dart'; |
3 | | |
|
4 | | | const localService = SquadronService.local(); |
5 | | |
|
6 | | | /// Annotation for service classes to be wrapped as workers. |
7 | | | class SquadronService { |
8 | | 0 | const SquadronService({ |
9 | | | this.pool = true, |
10 | | | this.targetPlatform = TargetPlatform.all, |
11 | | | String? baseUrl, |
12 | | | }) : baseUrl = baseUrl ?? '', |
13 | | | local = false; |
14 | | |
|
15 | | 0 | const SquadronService.web({bool pool = true, String? baseUrl}) |
16 | | 0 | : this(pool: pool, targetPlatform: TargetPlatform.web, baseUrl: baseUrl); |
17 | | |
|
18 | | 0 | const SquadronService.vm({bool pool = true}) |
19 | | 0 | : this(pool: pool, targetPlatform: TargetPlatform.vm); |
20 | | |
|
21 | | 11 | const SquadronService.local() |
22 | | | : pool = false, |
23 | | | local = true, |
24 | | | targetPlatform = TargetPlatform.all, |
25 | | | baseUrl = ''; |
26 | | |
|
27 | | | /// Controls code generation of a [WorkerPool] exposing the target service class. |
28 | | | /// `true` by default. |
29 | | | final bool pool; |
30 | | |
|
31 | | | /// Controls code generation of a [LocalWorkerClient] exposing the target service class. |
32 | | | /// `false` by default. |
33 | | | final bool local; |
34 | | |
|
35 | | | /// Controls code generation of a entry points for various platforms. |
36 | | | final int targetPlatform; |
37 | | |
|
38 | | | /// For Web-based workers, indicates the [baseUrl] where the Web Worker will |
39 | | | /// be exposed in production. |
40 | | | final String baseUrl; |
41 | | | } |