-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
345 additions
and
24 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,35 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
add Stream.asyncPush api | ||
|
||
This api creates a stream from an external push-based resource. | ||
|
||
You can use the `emit` helper to emit values to the stream. You can also use | ||
the `emit` helper to signal the end of the stream by using apis such as | ||
`emit.end` or `emit.fail`. | ||
|
||
By default it uses an "unbounded" buffer size. | ||
You can customize the buffer size and strategy by passing an object as the | ||
second argument with the `bufferSize` and `strategy` fields. | ||
|
||
```ts | ||
import { Effect, Stream } from "effect"; | ||
|
||
Stream.asyncPush<string>( | ||
(emit) => | ||
Effect.acquireRelease( | ||
Effect.gen(function* () { | ||
yield* Effect.log("subscribing"); | ||
return setInterval(() => emit.single("tick"), 1000); | ||
}), | ||
(handle) => | ||
Effect.gen(function* () { | ||
yield* Effect.log("unsubscribing"); | ||
clearInterval(handle); | ||
}), | ||
), | ||
{ bufferSize: 16, strategy: "dropping" }, | ||
); | ||
``` |
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,5 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
add `bufferSize` option to Stream.fromEventListener |
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
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.