Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Brolls31156yI’d say in this instance there’s likely little gained from doing it Rx-y unless you’re doing transformation / multi-observe on the result.
I’d stick to a promise and I’m sure Rx has a promise => observable function in there if you need to bridge the gap eventually. -
@Brolls Its for Native mobile (RxSwift and RxJava) there is no promise implementation without bringing in another framework. Guys want to use Rx to change how a lot of this stuff works (semi onboard with that idea).
They aren't using any multi, as far as I can see. They are using a lot of transformations, filtering, skipping etc.
But my point is:
func fetchData() -> Single<Data> {...}
func fetchData2() -> Single<Data> {...}
Observable.combineLatest(
fetchData.asObservable(),
fetchData2.asObservable()
).flatmap .............
If I only ever call fetchData and immediately convert it to an Observable, and never actually use it as a Single ... why should I not just cut out the middle man and return an Observable. Why is the "Rx way" to put a needless step in the middle to convert it -
Brolls31156yOh, that looks wrong to me.
I’d return Observable<Result> from each, no ToSingle and then use something like select many and switch to get the values out, but combinelatest is good too if you want that dual data at the same time. -
pain04861716yJust a stab in the dark coming from angular. But would a Single automatically unsubscribe where as an observable you would have to keep the reference and unsubscribe on tear down?
-
@pain0486 hhhmmm, yes I think you are correct, but is that benefit not negated when you convert it to an Observable?
Related Rants
-
danglingPointer8When someone at work says your Java multi threaded code is too advanced for other people to understand so you ...
-
GurpreetSK953RIP all the code I'll be refactoring 🙏😂
-
practiseSafeHex4Theres a debate in my company about whether or not to be using RxSwift on iOS apps. I'm not 100% convinced. To...
In Rx, what is the point of returning Single for all of our networking request responses, if every call to that method, first of all converts it to an Observable so that it can use flatMap, filters, combineLatest etc.
I get that Observable's have more overhead, Single can only return once, thats all clear. But is it not MORE overhead to create a Single, return it, convert it and now have the Observable we were trying to avoid in the first place.
I don't know if its just Rx I don't like, or how the team here is using it. But it is pissing me off, to no end, how massively overly complicated this is. It really feels to me like this is following a textbook approach while ignoring all the practical details.
<rant>
Next person to say "because its the Rx way", is getting a monitor thrown at their head.
</rant>
question
rx
rxjava
rxswift