中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
关系型数据库如何开启订阅分布式数据变化?
微信扫码分享
let devices: string | undefined = undefined; try { // 调用分布式数据订阅接口,注册数据库的观察者 // 当分布式数据库中的数据发生更改时,将调用回调 if(store != undefined) { (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver)=>{ if(devices != undefined){ for (let i = 0; i < devices.length; i++) { console.info(`The data of device:${devices[i]} has been changed.`); } } }); } } catch (err) { console.error('Failed to register observer. Code:${err.code},message:${err.message}'); }