RxFeedback.swift icon indicating copy to clipboard operation
RxFeedback.swift copied to clipboard

cannot send out multiple requests at the same time

Open Johnkui opened this issue 6 years ago • 3 comments

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 Observables for each request into one and map the merged Observable into signal<Command>. 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)
    }

Johnkui avatar May 14 '18 16:05 Johnkui

Hi @Johnkui,

you need to use Set overload of feedback loop, and not the optional one.

kzaher avatar May 15 '18 13:05 kzaher

thanks, @kzaher

Johnkui avatar Jul 23 '18 09:07 Johnkui

@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?

vadimtrifonov avatar May 16 '19 12:05 vadimtrifonov