Giter Site home page Giter Site logo

Comments (4)

frankpepermans avatar frankpepermans commented on May 18, 2024

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,
on the other hand single-subscriptions cannot be resubscribed to (it would throw).

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?

from rxdart.

frankpepermans avatar frankpepermans commented on May 18, 2024

or we let retry throw right away, with a proper message saying resubscription is impossible here

Here I mean, we throw even if no onError occurs, the retry operator simply should not be allowed on a single-subscription Observable

from rxdart.

brianegan avatar brianegan commented on May 18, 2024

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.

from rxdart.

lestathc avatar lestathc commented on May 18, 2024

Hi, @frankpepermans

For multi-subscription stream, the onListen side effect will only be trigged at the first time it is listened.
See: https://dartpad.dartlang.org/b25b41c71f035fd61cb16b4a9a6e3fab

So, I think either document that the retry won't trigger the onListen side effect, or change the api to something like:

retry(Stream streamCreator()) {
   ...
   onError: (_) {
      streamCreator().listen(streamController.add, ...)
   }
}

Then streamCreator will be used to restart side effect (like sending http request).

How do you think?

from rxdart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.