Skip to content

feat: Replay subject - #10

Closed
triandco wants to merge 4 commits into
fable-hub:mainfrom
triandco:feat/replay-subject
Closed

triandco wants to merge 4 commits into
fable-hub:mainfrom
triandco:feat/replay-subject

Conversation

@triandco

@triandco triandco commented Sep 7, 2023

Copy link
Copy Markdown
  • Implemented a variant of a subject that "replays" old values to new subscribers by emitting them when they first subscribe
  • Added two new test cases based on RxJs

Comment thread test/SubjectTest.fs
Comment on lines +128 to +130
// TODO: How should I be yielding here so that obv1.Notifications is populated?
// (I specifically don't want to emit a completion.)
do! Async.Sleep 1_000

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbrattli is there a better way to ensure the value is yielded without using Async.Sleep?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look, but currently on vacation so might take a few days 😬

Comment thread src/Subject.fs Resolved
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #10 (0da9516) into main (cb7f745) will increase coverage by 3.03%.
The diff coverage is 88.63%.

@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
+ Coverage   47.63%   50.67%   +3.03%     
==========================================
  Files          14       14              
  Lines        1100     1188      +88     
  Branches       44       46       +2     
==========================================
+ Hits          524      602      +78     
- Misses        564      572       +8     
- Partials       12       14       +2     
Flag Coverage Δ
unittests 50.67% <88.63%> (+3.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/Subject.fs 88.75% <88.50%> (-0.30%) ⬇️
src/AsyncObservable.fs 32.46% <100.00%> (+0.88%) ⬆️

@dbrattli dbrattli changed the title Replay subject feat: Replay subject May 1, 2026
@dbrattli dbrattli mentioned this pull request Oct 17, 2026
@dbrattli

Copy link
Copy Markdown
Collaborator

Thank you, @triandco, for proposing Replay Subject and for the work you put into this PR. It gave us the starting point for the feature.

I've adapted it to the current Fable.Reactive and Fable.Actor APIs in #50, including bounded FIFO replay, late completion and error delivery, and subscription disposal. Your question about avoiding Async.Sleep in the tests is addressed there with TestObserver.WaitUntil; the new subject also acknowledges a value after updating its replay buffer.

I'm closing this PR in favor of #50 so further review can happen in one place. Thanks again for getting this started!

@dbrattli dbrattli closed this Oct 17, 2026
dbrattli added a commit that referenced this pull request Oct 17, 2026
Adapt the replay subject proposed in #10 to the current actor-owned subject API. Preserve bounded FIFO replay and terminal notifications for late subscribers, and cover delivery without fixed sleeps.

Original proposal: triandco/AsyncRx#10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants