CouchDB pouchdb live对于实时聊天来说有点太快了

0md85ypi  于 2022-12-09  发布在  CouchDB
关注(0)|答案(1)|浏览(101)

我正在使用当前的VUEX突变同步到我的邮袋/ Couchdb,这是极好的。但是,当我在文本框中键入时,我可以键入太快,这可能意味着字母没有发送到同步,这很烦人,但不是杀手,但是如果我在中间编辑并以速度键入,有时光标会跳到最后,我想活作为其活的文字,但我想投票慢一点,有人有任何建议....有一个建议使用,因为:“现在”,但这似乎并没有使它慢下来

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)
      })
  })
},
fnatzsnv

fnatzsnv1#

我通过lodash为文本输入添加了一个去抖动功能,这对输入有很大帮助,但它并不完美,尤其是如果你在文本中间编辑,但很少跳到结尾和一般开始,更快的输入不是问题

相关问题