サイクル js http ドライバーを使用して、サイクル js でアプリケーションを作成しようとしています。3 回発生する呼び出しの応答サブスクリプションを次に示します。
ログインページで必要な1つのサブスクリプションと、メインで必要な別のサブスクリプション。それは次のようなものです:
ログインする:
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}})
主な機能:
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}})
どんな助けでも大歓迎です!!