-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to replay last N items of a Multi on subscription, or emit something predefined if nothing has been emitted yet #536
Comments
Do you have any specific use-case in mind? |
I filed this issue as a result of a Gitter discussion starting here: https://gitter.im/smallrye-io/community?at=608a65e5bdc0bc32e6258397 |
I went back thinking about this one.
Now Mutiny Is it what you had in mind? |
Yes. I don't think this feature would make much sense for cold streams, the entire feature implicitly assumes that there's a single broadcast that all subscribers listen to together. |
(notes for myself and the interested reader)
|
So I have something in draft in a scratchpad branch. How does that sound?
|
In that branch:
|
Do I understand it correctly that the variants without When I created this issue, I intentionally suggested |
If you omit calling upTo(n) (n > 0) then you get to replay all events once you subscribe.
If you do call upTo(n) then you get to replay the last n elements when you subscribe, and if the stream hasn't completed yet then you also receive the rest of the stream (like in a broadcast).
The seed will be prepended to the stream, so wether you receive these events or not depends on how much you are replaying (bounded / unbounded) and at which point in time you subscribe.
…On Thu, Mar 3, 2022, at 08:52, Ladislav Thon wrote:
Do I understand it correctly that the variants without `upTo()` will [maybe obtain the seed values and then] just join the broadcast? IOW, they are equivalent to `upTo(0)`?
When I created this issue, I intentionally suggested `createBy().replayingAtMost(int)` (or, in your parlance, `createBy().replayingUpTo(int)`) so that you can't skip the number of replayed items. If you didn't want to replay anything, just get the initial values and then join the broadcast, you'd have to say `0` explicitly, which perhaps looks weird, but then using a "replay" feature without actually replaying anything *should* look weird IMHO :-)
—
Reply to this email directly, view it on GitHub <#536 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAGK2KSUU2W7ZO7RCVTKGLU6BVSXANCNFSM43ZXAYOA>.
You are receiving this because you were assigned.Message ID: ***@***.***>
|
Ah so it's like |
Exactly! Long.MAX_VALUE is the default (aka replay everything).
…On Thu, Mar 3, 2022, at 09:05, Ladislav Thon wrote:
Ah so it's like `upTo(Long.MAX_VALUE)`, roughly :-) OK, that makes sense.
—
Reply to this email directly, view it on GitHub <#536 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAGK2NTHDNJ3LLKSWPW7ODU6BXEBANCNFSM43ZXAYOA>.
You are receiving this because you were assigned.Message ID: ***@***.***>
|
Replay a Multi (turned into a hot stream) to multiple (possibly late) subscribers. See #536 for the initial discussion.
Replay a Multi (turned into a hot stream) to multiple (possibly late) subscribers. See #536 for the initial discussion.
Replay a Multi (turned into a hot stream) to multiple (possibly late) subscribers. See #536 for the initial discussion.
Replay a Multi (turned into a hot stream) to multiple (possibly late) subscribers. See #536 for the initial discussion.
Replay a Multi (turned into a hot stream) to multiple (possibly late) subscribers. See #536 for the initial discussion. Documentation fixes were contributed by: Co-authored-by: Ladislav Thon <[email protected]> Co-authored-by: Clement Escoffier <[email protected]>
Rx has a concept of
BehaviorSubject
andReplayingSubject
, which are quite similar and serve a very useful purpose: pre-seed a subscriber with last known value[s] / initial value[s] at the moment of subscription. I think we could unify them under an API like this:Calling it
replayingAtMost
to highlight that if you set 5 items to replay but only 3 items have been emitted, then only 3 will be replayed to a new subscriber. If you think that's intuitive enough, can shorten to justreplaying
.WDYT?
The text was updated successfully, but these errors were encountered: