-
Notifications
You must be signed in to change notification settings - Fork 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
Fixing potential issue with RxSwift request method #1294
Conversation
SwiftLint found issuesWarnings
Generated by 🚫 Danger |
Codecov Report
@@ Coverage Diff @@
## master #1294 +/- ##
==========================================
+ Coverage 83% 83.04% +0.04%
==========================================
Files 24 24
Lines 753 755 +2
==========================================
+ Hits 625 627 +2
Misses 128 128
Continue to review full report at Codecov.
|
Hmm, I have a feeling you should be storing a strong reference to your provider somewhere instead. This reminds me of #1267, can you try that and see if it fixes your issue? |
|
I'm reading through RxSwift's guide to disposing and, in my potentially uninformed mindset of things Rx, it seems to me like you have to hold onto your provider if you want your subscriptions to stay alive. Can we arrive at a consensus for that? @sunshinejr @pedrovereza @freak4pc what do you think? Also, if that is the case, maybe we shouldn't be capturing |
I believe we always guided to retain the provider to get the correct behavior. We will need to investigate why there is no response for a |
@iwheelbuy thanks a lot, I did not know about it before, but nevertheless, even if a request was released there should be at least an error. |
@volodg I disagree, I think Rx's philosophy is to do nothing when an Observable is disposed, the pattern doesn't recommend sending an error event before disposing. |
@AndrewSB how to handle the disposed case when no callback is called? |
@AndrewSB I agree in the terms of Rx, but the
This makes me think that implementing an error there might be the right thing to do to not break the contract. What do you think? |
I think we should do whatever RxSwift does whenever a @volodg do you want to try to see what happens and post your findings? |
@sunshinejr: this may be a good candidate for hacktoberfest! |
@AndrewSB let singleStream = Observable<Int>
.interval(1, scheduler: MainScheduler.instance)
.timeout(1, scheduler: MainScheduler.instance)
.asSingle()
.do(onNext: { _ in
print("onNext")
}, onError: { _ in
print("onError")
}, onSubscribe: {
print("onSubscribe")
}, onSubscribed: {
print("onSubscribed")
}, onDispose: {
print("onDispose")
})
singleStream.subscribe().dispose() prints:
|
#1311 does The Right Thing and supersedes this |
Before anything else, thank you for this library. Recently, I attempted to network with the server using the
request
method ofRxSwift
Unfortunately, I received no response.I assume it was due to the fact that
Single<Response
has been captured asweak
within the RxProvider’screate
closure. I propose that it is better to have a potential retain cycle rather than having no response at all. Therefore, I’ve tried to circumvent the issue by having it similar to that of therequestWithProgress
method which retains. Again, I appreciate your service for the community.