-
Notifications
You must be signed in to change notification settings - Fork 272
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 operator did not re-trigger onListen/onSubscribe side effect #69
Comments
There's an important gotcha to consider here, In Dart we have 2 Stream types, single-subscription and multi-subscription. For multi-subscription, there is no issue, we simply resubscribe when onError triggers, For the latter, either we simply swallow the Error, pretty much the current retry implementation, or we let retry throw right away, with a proper message saying resubscription is impossible here thoughts? |
Here I mean, we throw even if no onError occurs, the retry operator simply should not be allowed on a single-subscription Observable |
Yeah, another tricky difference between the two implementations! That's an interesting idea -- perhaps the best way would be to add an assert clause at the earliest possible point that would inform the developer that retry only works with multi-subscription streams. That way we can "fail fast" and inform the developer of the mistake, rather than swallowing the developer error. |
Hi, @frankpepermans For multi-subscription stream, the onListen side effect will only be trigged at the first time it is listened. So, I think either document that the retry(Stream streamCreator()) {
...
onError: (_) {
streamCreator().listen(streamController.add, ...)
}
} Then How do you think? |
* Fixes #69: Create Retry factory that allows a stream to be retried N number of times. * Fix controller not being properly closed * Fix single-subscription bug * Simplify Defer implementation, add single-subscription check as well
As described in ReactiveX
retry
operator, current observable should be resubscribed once an error occurs.But existing implementation does not do that.
The text was updated successfully, but these errors were encountered: