You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: update scoped service layer pattern to use Effect.Service's scoped property
Update pattern to use Effect.Service's scoped property instead of Layer.scoped
Add proper resource cleanup with Effect.addFinalizer
Improve example with better type definitions and comments
Fix program execution to use Effect.scoped properly
Regenerate published version through pipeline
This fixes the pattern to show the recommended way of creating service layers around managed resources in Effect.
description: "Provide a managed resource to the application context using the `scoped` property of Effect.Service."
9
+
description: "Provide a managed resource to the application context using `Layer.scoped`."
10
10
related: ["acquire-release-bracket"]
11
11
author: "PaulJPhilp"
12
12
---
@@ -15,7 +15,7 @@ author: "PaulJPhilp"
15
15
16
16
## Guideline
17
17
18
-
Define a service using `class MyService extends Effect.Service(...)`. Implement the service using the `scoped` property of the service class. This property should be a scoped`Effect` (typically from `Effect.acquireRelease`) that builds and releases the underlying resource.
18
+
Define a service using `class MyService extends Effect.Service(...)` and provide a `scoped` property in the implementation object. This property should be an`Effect` (typically from `Effect.acquireRelease`) that builds and releases the underlying resource.
19
19
20
20
## Rationale
21
21
@@ -24,36 +24,52 @@ This pattern is the key to building robust, testable, and leak-proof application
Copy file name to clipboardExpand all lines: content/raw/scoped-service-layer.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ author: "PaulJPhilp"
15
15
16
16
## Guideline
17
17
18
-
Define a service using `class MyService extends Effect.Service(...)`. Implement the service using the `scoped` property of the service class. This property should be a scoped`Effect` (typically from `Effect.acquireRelease`) that builds and releases the underlying resource.
18
+
Define a service using `class MyService extends Effect.Service(...)` and provide a `scoped` property in the implementation object. This property should be an`Effect` (typically from `Effect.acquireRelease`) that builds and releases the underlying resource.
0 commit comments