【发布时间】:2020-06-27 20:27:41
【问题描述】:
我正在使用当前的 vuex 突变来同步到我的 pouch/couchdb,这非常棒。然而 当我在文本框中输入时,我可能输入速度太快,这可能意味着字母不会发送到同步,这很烦人但不是杀手但是如果我在中间编辑并快速输入有时光标会跳到最后,我希望作为实时文本进行直播,但我想稍微慢一点,有人有什么建议吗....有人建议使用 since : 'now' 但这似乎并没有减慢速度
syncDB: () => {
pouchdb.replicate.from(remote).on('complete', function () {
store.commit('GET_ALL_NODES')
store.commit('GET_MY_NODES')
store.commit('GET_POSITIONS')
store.commit('GET_CONNECTIONS')
store.commit('GET_EMOJI')
// turn on two-way, continuous, retriable sync
pouchdb
.sync(remote, {
live: true,
retry: true,
attachments: true,
})
.on('change', function () {
// pop info into function to find out more
store.commit('GET_ALL_NODES')
store.commit('GET_MY_NODES')
store.commit('GET_POSITIONS')
store.commit('GET_CONNECTIONS')
store.commit('GET_EMOJI')
})
.on('paused', function () {
// replication paused (e.g. replication up to date, user went offline)
// console.log('replication paused')
})
.on('active', function () {
// replicate resumed (e.g. new changes replicating, user went back online)
//console.log('back active')
})
.on('denied', function () {
// a document failed to replicate (e.g. due to permissions)
})
.on('complete', function () {
// handle complete
})
.on('error', function (err) {
console.log(err)
})
})
},
【问题讨论】:
-
我认为这不是 PouchDB 本身的问题,而是在 Vue 组件中。你用什么 v-on 监听器?如果您碰巧使用
@input切换到@change,或@keydown.enter.prevent或@blur,那么该事件将在您完成输入后而不是在输入中间发出。
标签: vue.js couchdb vuex pouchdb