0

I am trying to write an application in cycle js using the cycle js http driver. Here's the response subscriptions for the call which is getting fired 3 times.

One subscription i need in the login page and another in the main. It's like:

login:

const response$ = http
    .filter(res => res.request.url.indexOf("test/v3/users/login")>=0)
    .flatMap(x => x.catch(err => Observable.just({err})))
    .map(response => {
        if(isErr(response)){
            return extractError(response)
        }
        else{
            return extractResponse(response)
        }
    })

const x$ = response$.filter(x => x.status === "success").map(x => {return {key: "b", value: x.session.b_token}})

main function:

const loginStorage$ = sources.http
    .filter(res => res.request.url.indexOf("test/v3/users/login")>=0)
    .flatMap(x => x.catch(err => Observable.just({err})))
    .map(response => {
        if(isErr(response)){
            return extractError(response)
        }
        else{
            return extractResponse(response)
        }
    })
    .filter(x => x.status === 'success').map(x => {return {key: "a", value: x.session.id}})

Any help appreciated!!

  • 1
    Please provide more context. Architecturally, how does `login` relate to `main`? Can you provide more code? Or set up the error you're getting on [WebpackBin](http://www.webpackbin.com/)? – bloodyKnuckles Jun 20 '16 at 14:33
  • Try `{eager: true}` option for HTTP driver. – WHITECOLOR Jun 24 '16 at 12:36

0 Answers0