【发布时间】:2019-09-27 16:43:45
【问题描述】:
我想使用 async/await 重写以下内容
db.replicate.from(remoteCouch).on(
'complete', (info) => {
db.sync(remoteCouch, { live: true, retry: true })
})
如何使用 await 处理 on 事件?
会
var res = await db.replicate.from(remote)
res.on('complete', (info) => {
db.sync(remote, opts)
})
工作?
我需要对回调进行额外的 async/await 吗?
【问题讨论】:
-
像任何其他回调函数一样将其包装在一个 Promise 中。
标签: javascript asynchronous pouchdb ecmascript-2016