Skip to content
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

cannot send out multiple requests at the same time #30

Open
Johnkui opened this issue May 14, 2018 · 3 comments
Open

cannot send out multiple requests at the same time #30

Johnkui opened this issue May 14, 2018 · 3 comments

Comments

@Johnkui
Copy link

Johnkui commented May 14, 2018

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. 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
Copy link
Member

kzaher commented May 15, 2018

Hi @Johnkui,

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

@Johnkui
Copy link
Author

Johnkui commented Jul 23, 2018

thanks, @kzaher

@vadimtrifonov
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants