-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add materialize and dematerialize for Single #1970
Conversation
2a9926a
to
411d032
Compare
411d032
to
50492e9
Compare
If this is accepted, you'll want both. The if question is for Krunoslav, not myself. |
50492e9
to
46e875f
Compare
46e875f
to
f5a7a71
Compare
Hi @MortyMerr , The author suggested this example as a use case: let events = source.flatMap { [service] in
service.get().asObservable().materialize()
}
.share()
events.elements().bind(to: ...)
events.error().bind(to: ...) I'm confused by the implementation.
If we want to be as type safe as possible I think that the interface would be
I don't see any benefit of converting I'm now thinking that we might want to change I think that request.materialize().mapEventSomehow.dematerialize() ... but I guess that would be weird to me. Single already has "monadish" behavior. I'm not sure what would be the benefit of doing that. I think that using Rx in this way let events = source.flatMap { [service] in
service.get().asObservable().materialize()
}
.share()
events.elements().bind(to: ...)
events.error().bind(to: ...) is not the best idea:
And yes, we have these kinds of examples in our repo also, but to me they are more of an operator playground than advice how to ideally design systems. |
Hi @kzaher
It was just an example. "There might be" is a different question :) If there is a need of handling loading state - this code will be changed. |
This won't make much sense because you'll lose the type, even when using I think having I would prefer having |
After reading the conversation in this PR and the linked issue, I don't understand, from a conceptual point of view, why I'm just curious how do people handle errors for Single. I do find myself using |
I am ready to change implementation in any moment, I am really interested in it. The main question is about a return type from Sent with GitHawk |
Sorry for all the time it took to answer, I've been super busy. I think having a materialize from I'm not sure if you're still involved in adding this @MortyMerr. |
a5f25b6
to
d02b69f
Compare
d02b69f
to
fcf1a46
Compare
Hey @freak4pc thank you for your answer and sorry for late response. I removed all changes except |
@freak4pc I am not sure why CI is failing. Local tests passed successfully. |
Hey @freak4pc why was this closed? |
Just because we got rid of |
Working with
Single
events instead of elements might be important in some cases. For instance withRxSwiftExt
.elements()
and.errros()
operators. Usingsingle.asObervable().materialize()
looks strange for me. It can be cutted to simplesingle.materialize()
.I can't see any reasons why this operator is not added to
PrimitiveSequence
.Here is the same PR for RxJava - ReactiveX/RxJava#6278