云数据库开发Watcher不能关闭问题?
在page上方生命watch
var watcher =null;
在onload和onshow中启动watch
watcher = db.collection("chat").where(
_.or([{
fromUserID:app.globalData.userInfo._id,//"2a7b532a5fcb2e8000e02a3926e2fa08", //
toUserID:this.data.curUserInfo._id, //"2a7b532a5fcbac6e00e77d6b21baeff1",
},{
fromUserID:this.data.curUserInfo._id,//"2a7b532a5fcbac6e00e77d6b21baeff1",
toUserID:app.globalData.userInfo._id,//"2a7b532a5fcb2e8000e02a3926e2fa08"
}])).orderBy("updateTime","desc").limit(20).watch({
onChange: function(snapshot) {
....}
在OnLoad和OnHide中关闭watcher
if(watcher != null){
console.log(' close watcher',watcher)
watcher.close();
}
发现,返回页面时,执行了onload,但是未关闭watcher
iphone 在小程序界面,直接返回桌面,watcher也没关掉,
退出小程序或者关闭手机屏幕才会真正关闭watcher,请教各位大佬什么问题