-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve scopes in stream operations (#3989)
- Loading branch information
Showing
15 changed files
with
1,143 additions
and
974 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
Ensure scopes are preserved by stream / sink / channel operations | ||
|
||
**NOTE**: This change does modify the public signature of several `Stream` / `Sink` / `Channel` methods. Namely, certain run methods that previously removed a `Scope` from the environment will no longer do so. This was a bug with the previous implementation of how scopes were propagated, and is why this change is being made in a minor release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
Add `Effect.scopedWith` to run an effect that depends on a `Scope`, and then closes the `Scope` after the effect has completed | ||
|
||
```ts | ||
import { Effect, Scope } from "effect" | ||
|
||
const program: Effect.Effect<void> = Effect.scopedWith((scope) => | ||
Effect.acquireRelease( | ||
Effect.log("Acquiring..."), | ||
() => Effect.log("Releasing...") | ||
).pipe(Scope.extend(scope)) | ||
) | ||
|
||
Effect.runPromise(program) | ||
// Output: | ||
// timestamp=2024-11-26T16:44:54.158Z level=INFO fiber=#0 message=Acquiring... | ||
// timestamp=2024-11-26T16:44:54.165Z level=INFO fiber=#0 message=Releasing... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.