}).watch({ onChange: function (snapshot) { if (cb) cb(snapshot) }, onError: function (err) { console.error('the on_off_model_state watch closed because of error', err) } }) }
this.listenGroupChange = function (openid, cb) { console.log('watch openid:'+openid) groupWacth= db.collection('groups').where({ _openid: openid }).watch({ onChange: function (snapshot) { if (cb) cb(snapshot) }, onError: function (err) { console.error('the groups watch closed because of error', err) } }) } this.listenNodeChange = function (openid, cb) { nodesWatch= db.collection('provisioned_nodes').where({ _openid: openid }).watch({ onChange: function (snapshot) { if (cb) cb(snapshot) }, onError: function (err) { console.error('the watch closed because of error', err) } }) }
代码怎么写的
CloudController.listenGroupChange(context.curOpenid(),
function
(snapshot) {
context.globalData.groups = snapshot.docs
context.notifyGroupsChange()
})
CloudController.listenNodeChange(context.curOpenid(),
function
(snapshot) {
context.provisionedNodes = snapshot.docs
context.notifyProvisionedChange()
})
有经验的帮忙解答一下。谢谢各位了