智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/c1/c148da875f73573256d1773a552...

24 lines
595 B

const vdSyncHandlers = Object.create(null)
export function registerVdSync (pageId, callback) {
(vdSyncHandlers[pageId] || (vdSyncHandlers[pageId] = [])).push(callback)
}
export function removeVdSync (pageId) {
delete vdSyncHandlers[pageId]
}
export default function onVdSync ({
data,
options
}, pageId) {
const handlers = vdSyncHandlers[pageId]
if (Array.isArray(handlers)) {
handlers.forEach(handler => {
handler(data)
})
} else {
// 页面关闭时可能会赶上触发同步,此时页面已销毁
// console.error(`vdSync[${pageId}] not found`)
}
}