-
Notifications
You must be signed in to change notification settings - Fork 68
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
previous request are cancelled by the following request #36
Comments
Use a set overload of feedback loop or create your own feedback loop. |
@kzaher i updated the question, and the demo address was set. Thx |
The problem is a misusage of the library. You are using Requests which is a reference type as a storage of the requests but IN the query this line If the above doesn't make sense to you, then think of how you would it if you have only one request. Instead of the Requests class just use the Set in the State and keep the RequestType in the Set until you get a response. In case you are not interested in the result of some RequestType remove it from the Set and the |
I'm using the RxFeedback in my project, and i got a problem that a processing network request will be cancelled by the follwing request.
To describe the question clearly, i made a demo here.
the UI is below, it's simple
If 'request 1' button taped, a simulative request will be send, and delay to 2.0s, the button below will show 'response 1 received'.
and if 'request 2' button taped, 'response 2 received' will display the same way.
While, the problem is that if 'request 1' button taped, and before response 1 received, i taped the 'request 2' button, then the response 1 will never come back, it is cancelled.
And if i make debug here:
let event = just.delay(2.0) .debug(query.debugIdentifier, trimOutput: false)
i will got the following log:
---- request 1 ----
-> subscribed
---- request 2 ----
-> subscribed
---- request 1 ----
-> isDisposed
---- request 2 ----
-> Event next(response(RxFeedbackQueryTest.RequestType.second))
---- request 2 ----
-> Event completed
---- request 2 ----
-> isDisposed
we can see that request 1 was disposed once request 2 is subscribed
after reading the source codes of RxFeedback, i think, the codes leading the problem is below:
by using 'flatMapLatest' and 'switchLatest' operators, the previous sequence will be disposed,
why did you design to cancel the previous 'query' if a new 'query' comes?
can i just replace the 'flatMapLatest' with 'flatMap', and remove the operation 'takeUntilWithCompletedAsync'?
and how 'takeUntilWithCompletedAsync' can avoid the reentrancy issues?
The main code is below:
` private func setupBinding() {
`enum Event {
case none
case request(RequestType)
case response(RequestType)
case clear
}
struct State: Mutable {
}`
The text was updated successfully, but these errors were encountered: