-
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Tim Smart <tim.smart@arisechurch.com>
- Loading branch information
Showing
4 changed files
with
357 additions
and
63 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,18 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
add `replay` option to PubSub constructors | ||
|
||
This option adds a replay buffer in front of the given PubSub. The buffer will | ||
replay the last `n` messages to any new subscriber. | ||
|
||
```ts | ||
Effect.gen(function*() { | ||
const messages = [1, 2, 3, 4, 5] | ||
const pubsub = yield* PubSub.bounded<number>({ capacity: 16, replay: 3 }) | ||
yield* PubSub.publishAll(pubsub, messages) | ||
const sub = yield* PubSub.subscribe(pubsub) | ||
assert.deepStrictEqual(Chunk.toReadonlyArray(yield* Queue.takeAll(sub)), [3, 4, 5]) | ||
})) | ||
``` |
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.