-
Notifications
You must be signed in to change notification settings - Fork 330
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
retry() only works with observables that return one event #721
Comments
As you suggested, let's assume for a moment that
This repeating of events may be a problem for the consumer of the stream. In Bacon
... to swallow all errors, except the first ...
... which gives us in a way retryable promises. Very nice! |
But am I wrong to think that a Promise (admittedly the main use-case) only have two possible outcomes:
So I was thinking, with the proposed changed behaviour, the user would still only ever see a a single What is the use case (in the current mode) for using Bacon.retry with an observable that returns multiple values? |
I guess someone could do:
Now the stream could be:
And I suppose But wouldn't that be what the user wants? Otherwise, why not restrict the |
correct I guess
I can't see any use case. The disappearing trailing error events are a little "spooky".
Yes I guess that would be the logical consequence. Besides to I often wrap promises (and make them cancelable) with |
Sure, that's one option, but my point was that But if I want to retry an observable that has more than a single event, why wouldn't Bacon let me? |
Ok I basically understand your issue, however I would still object against unreproducible multiple emission of events. (Those leading up to the error which eventually causes the repeats of the sequence). I mean, a "successful" stream (without an error) consists of all events up to the Now if, as in your case, just // a regular source function for Bacon.retry
var generate = cAttempts => Bacon.sequentially(100, [0, 1, 2, cAttempts < 2 ? new Bacon.Error("oops!") : 3]);
// helper function
var reduce = s => s.reduce([], (acc, x) => R.concat(acc, [x]));
Bacon.retry({source: R.compose(reduce, generate), retries: 2}).flatMap(Bacon.fromArray);
// -> 0,1,2,3,<end>
Bacon.retry({source: R.compose(reduce, generate), retries: 1}).flatMap(Bacon.fromArray)
// -> <error>, <end>
|
If the
source
stream of aBacon.retry()
returns first aBacon.Next()
event before it returns aBacon.Error
, retry will consider the stream finished. I would have expected that the stream will retry until there is aBacon.End
. The documentation does not talk about this at all.Is there room to change the behaviour for Bacon 3?
The text was updated successfully, but these errors were encountered: