cannot send out multiple requests at the same time
Johnkui opened this issue · 3 comments
Johnkui commented
I'm using the RxFeedback on my project. And one of the business is to send out multiple requests when entering a specific page. So I change the State
and in the side-effects callback I merge those Observable
s for each request into one and map the merged Observable
into signal. however, only one request data is refreshed by the Driver
though all the requests came back. What am I doing incorrectly?
here is my code FYI:
internal static func sideEffect(query: Query,
with dependancy: Dependancy) -> Signal<Command> {
if query.urls.count > 0 {
return dependancy.api
.makeRequests(apis: query.urls,
constrained: dependancy.constrained)
.asSignal(onErrorJustReturn: .failure(.unknown))
.map(Command.reponseReceived)
}
return Signal.empty()
}
func request(apis: [URLType]) -> Observable<Response> {
let observables: [Observable<Response>] =
apis.flatMap { api in
return
Cornerstone
.NetworkProxy
.implementor
.response(api: api, url: api.URL, get: api.query)
.map {
if let data = ... as? [String: Any] {
return .success((data: data, type: api))
}
return .failure(.unknown)
}.catchErrorJustReturn(.failure(.unknown))
}
return Observable.merge(observables)
}
kzaher commented
Hi @Johnkui,
you need to use Set
overload of feedback loop, and not the optional one.
vadimtrifonov commented
@kzaher What if some service produces two responses: (1) cached data, (2) freshly fetched data? From what I see RxFeedback allows only one emission from an effect, or I missed something?