Coder Social home page Coder Social logo

Comments (7)

joshaber avatar joshaber commented on April 16, 2024

Yeah I've wondered about this before...

Note that RACAsyncSubject does behave slightly differently. It only sends the next when it completes, whereas RACReplaySubject sends them as it gets them.

I think the real value is the semantic difference between the two. RACAsyncSubject says you're sending a single value. It's a promise or a future or whatever. Point being it's just one thing. RACReplaySubject says you want to catch up anyone that missed anything, but still act like a stream. I think that difference communicated by different types is valuable.

I'd be interested in getting @xpaulbettsx's thoughts on this.

from reactivecocoa.

anaisbetts avatar anaisbetts commented on April 16, 2024

So, the only difference between them that should be there is that AsyncSubject doesn't replay non-last items - with both of them, until it completes (i.e. when it's still "live"), they both just act like a normal Subject. If you got rid of AsyncSubject it probably would be fine. On .NET, AsyncSubject has some additional secret-sauce to support the await keyword, so it makes more sense that it is a separate class.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 16, 2024

@joshaber The typical use case for RACAsyncSubject seems to be network operations, which I think are absolutely better modeled as a stream, and not as a future.

I think the problem is that RACAsyncSubject is somewhat fragile. If you send more than one value, suddenly the behavior of any subscribers becomes a lot less deterministic. I can't think of a case where I wouldn't want a RACReplaySubject instead.

I think that difference communicated by different types is valuable.

It's worth noting that interfaces typically shouldn't expose whether a RACAsyncSubject or RACReplaySubject is being returned. Callers should just see a RACSubscribable, and how it handles asynchronous behavior is either described in documentation, or an implementation detail.

from reactivecocoa.

joshaber avatar joshaber commented on April 16, 2024

Yeah good point 👍

from reactivecocoa.

joshaber avatar joshaber commented on April 16, 2024

FWIW, I'm going to do a pass through soon to do some housekeeping. I can remove RACAsyncSubject and RACBehaviorSubject when I do that.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 16, 2024

🤘 Sounds good, though we should keep in mind that RACAsyncSubject got some important concurrency fixes which RACReplaySubject might not have.

from reactivecocoa.

joshaber avatar joshaber commented on April 16, 2024

✨ 👍

from reactivecocoa.

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.