我有一个类似下面的承诺链,其中有三个承诺。我现在一直在研究Rx.js,在将这些承诺转换为可观察对象并将这些信息链接到不同的函数时,我无法弄清楚从哪里开始。如果可能的话,我真的很感激一些指导/知识。
export function pushCustomers (mongo, shopify) {
return getDocsWhereRequest(mongo, 'shopify_customers').map(customer => {
return createCustomer (shopify, customer.shopifyRequest).then(shopifyResponse => {
return updateCollection(mongo, 'shopify_customers', {email: customer.email}, {shopifyResponse})
}).catch(err => {
if (!_.get(err, 'response.body.errors')) throw err
let shopifyResponseError = JSON.stringify(err.response.body.errors)
return updateCollection(mongo, 'shopify_customers', {email: customer.email}, {shopifyResponseError})
})
})
}
答案 0 :(得分:0)