从pouchdb sync调用方法

时间:2016-08-12 16:12:49

标签: pouchdb

我有类似这样的课程设置

class FinanceDB {

  constructor() {
    this.PouchDB = require('pouchdb');
    this.db = new this.PouchDB('fin'); //8080
    this.remoteDB = new this.PouchDB('http://localhost:5984/rfin');

    this.db.sync(this.remoteDB, {
      live: true,
      retry: true
    }).on('change', function (change) {

      console.log('yo, something changed!');
      this.dosomething();

    }).on('error', function (err) {
      console.log("error", err);
      // yo, we got an error! (maybe the user went offline?)
    })
  };

  dosomething() {
    console.log('what now?');
  };
}

当数据库发生变化时,控制台会显示“哟,有些东西发生了变化!'正如所料。但我的班级方法永远不会运行,我也不会有任何错误。如何从pouchdb sync内部调用方法?

0 个答案:

没有答案