Feature: Emit something before retry. #6646
Replies: 3 comments 2 replies
-
would it be bad to expose the observer in |
Beta Was this translation helpful? Give feedback.
-
Personally, I think that this proposal would make the API or I mean, I've read the behavior that you have described, and yes, after reading that, it's reasonable and it makes sense, but it feels a bit arbitrary. Just by having a look at the API that's not the behavior that I would have guessed. IMHO a cleaner approach would be to pass the source$.pipe(
catchError((err, caught, count) => {
// log the error so we can see it.
console.error(error);
// delay the retry by some time
return timer(5000).pipe(
concatMapTo(caught),
startWith({ type: 'RETRY', error, count }),
)
})
) |
Beta Was this translation helpful? Give feedback.
-
What about adding a config parameter to re-throw the error. Then you would be able to use the catchError operator after the retry operator to log/emit another value. I do also like the original proposal. "Visibility of system status" is an important usability heuristic and currently the retry operator makes it difficult to expose the observable's current state. |
Beta Was this translation helpful? Give feedback.
-
Issue this would address:
Frequently I find myself writing code to dance around the fact that I want to do things like display the number of retry attempts as I'm retrying. Currently, I've just been using a side effect to do that, but it would be nice if I could output the retry attempts or a retry message in to the same output stream.
The problem with this approach is I've found it's better to mix connection status, or upload progress, or whatever, into the same stream as the output data, and share/filter it appropriately later.
Proposed solution:
Add a configurable/optional function that can be used to select a temporary observable that will be run until the retry commences. This can also be used for synchronous retry. In this case I'm calling it
emitOnRetry
, but we can bikeshed that name.The behavior of the above:
source$
errors, callemitOnRetry
, and immediately subscribe to the resulting observable input, flattening results into the resulting observabledelay
.delay
emits, immediately unsubscribe from theemitOnRetry
observable and execute appropriate retry logic.In the synchronous retry case (when
delay
is not provided), this wouldn't work any different. IfemitOnRetry
returned a synchronous source, it would have a chance to emit whatever it was before the sync retry logic fired.Pros
retry
, which is already an improvement overretryWhen
and the previous retry.catchError
thenrepeat
, but that would not have allowed for access to the retry count.Cons
Beta Was this translation helpful? Give feedback.
All reactions