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!!