0
我有一類設置這樣調用方法
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同步中調用方法?