@@ -35,6 +35,24 @@ dev_dependencies:
3535
3636Don't forget to exclude the ` .catalyst_builder_cache` directory from VCS.
3737
38+ # # Config reference
39+
40+ Some parts of the builder can be configured by adding a `catalyst_builder` section to the `pubspec.yaml`
41+
42+ ` ` ` yaml
43+ # pubspec.yaml
44+ name: your_package
45+ # dependencies:
46+ # catalyst_builder:
47+ # ...
48+ catalyst_builder:
49+ cacheDir: '.cache/catalyst_builder'
50+ ` ` `
51+
52+ | Property | Type | Description | Default |
53+ |------------|---------|------------------------------------------------------|-------------------------|
54+ | `cacheDir` | String? | The path to the cache directory for preflight files. | .catalyst_builder_cache |
55+
3856# # Usage
3957
4058Decorate your services with `@Service` :
@@ -45,6 +63,7 @@ class MyService {}
4563` ` `
4664
4765Decorate in your entry point file any top level symbol with `@GenerateServiceProvider` :
66+
4867` ` ` dart
4968// my_entrypoint.dart
5069
@@ -72,7 +91,7 @@ import 'my_entrypoint.catalyst_builder.g.dart';
7291void main() {
7392 // Create a new instance of the service provider
7493 var provider = DefaultServiceProvider();
75-
94+
7695 // Boot it to wire services
7796 provider.boot();
7897
@@ -102,10 +121,10 @@ class SingletonService {}
102121class TransientService {}
103122` ` `
104123
105- | Lifetime | Description |
106- | --------- | ----------- |
124+ | Lifetime | Description |
125+ |-----------| ---------------------------------------------------------------------------------- |
107126| Singleton | The instance is stored in the provider. You'll always receive the same instance. |
108- | Transient | Everytime you call `resolve` or `tryResolve` you'll receive a fresh instance. |
127+ | Transient | Everytime you call `resolve` or `tryResolve` you'll receive a fresh instance. |
109128
110129# ## Exposing
111130
@@ -241,6 +260,7 @@ void main() {}
241260# # Registering services at runtime (v2.1.0+)
242261
243262Sometimes you need to register services at runtime. For this, you can use the `register` method :
263+
244264` ` ` dart
245265void main() {
246266 var provider = ExampleProvider();
@@ -255,10 +275,11 @@ void main() {
255275` ` `
256276
257277# # Create a sub-provider with additional services / parameters (v2.2.0+)
278+
258279In some cases, you want to register services or parameters only for a specific service.
259- The services or parameters should not be placed inside the global service provider.
260- To solve this problem, you can use the `enhance` method, which accepts an array of additional services and
261- a map of additional parameters. These are only available in the returned ServiceProvider.
280+ The services or parameters should not be placed inside the global service provider.
281+ To solve this problem, you can use the `enhance` method, which accepts an array of additional services and
282+ a map of additional parameters. These are only available in the returned ServiceProvider.
262283
263284` ` ` dart
264285void main() {
@@ -271,7 +292,7 @@ void main() {
271292 services: [
272293 // Important: Specify the type explicitly or cast the outer array to dynamic. Otherwise dart can not infer the
273294 // correct return type!
274- LazyServiceDescriptor<MySelfRegisteredService>(
295+ LazyServiceDescriptor<MySelfRegisteredService>(
275296 (p) => MySelfRegisteredService(p.resolve(), p.parameters['foo']),
276297 const Service(exposeAs: SelfRegisteredService),
277298 ),
@@ -284,8 +305,10 @@ void main() {
284305` ` `
285306
286307# # Tagged services (v2.3.0+)
308+
287309You can tag services using the `tags` property on the `Service` annotation. This is useful if you need to group services
288310and load all services with a certain tag at once.
311+
289312` ` ` dart
290313@Service(tags: [#groupTag, #anotherTag])
291314class MyService1 {}
@@ -315,6 +338,7 @@ void main() {
315338# # Inject tagged services (v3.2.0+)
316339
317340The `@Inject` annotation allows you to inject a list of services tagged with a certain tag.
341+
318342` ` ` dart
319343abstract class MyServiceBase {}
320344
@@ -326,10 +350,8 @@ class MyService2 extends MyServiceBase {}
326350
327351@Service()
328352class ServiceWithDeps {
329-
330- ServiceWithDeps(
331- @Inject(tag: #groupTag) List<MyServiceBase> services,
332- ) {
353+
354+ ServiceWithDeps(@Inject(tag: #groupTag) List<MyServiceBase> services,) {
333355 // services includes MyService1 and MyService2
334356 }
335357}
@@ -339,10 +361,12 @@ class ServiceWithDeps {
339361# # Include services from dependencies
340362
341363By default, the builder includes only services from the root package.
342- If you've dependencies that provides decorated services (`@Service`) you need to set `includePackageDependencies` to true.
364+ If you've dependencies that provides decorated services (`@Service`) you need to set `includePackageDependencies` to
365+ true.
366+
343367` ` ` dart
344368@GenerateServiceProvider(
345369 providerClassName: 'ExampleProvider',
346- includePackageDependencies: true, // Set this to true
370+ includePackageDependencies: true, // Set this to true
347371)
348372` ` `
0 commit comments