[AI Generated]: refactor(*): 对齐 SDK demo 模式,移除 bus 标志位,依赖 Blue.stop() 清空订阅,onShow 直接重新 subscribe
This commit is contained in:
@@ -151,23 +151,11 @@ App({
|
||||
this.globalData.ppScale.plugin = requirePlugin('ppScale-plugin');
|
||||
},
|
||||
|
||||
// 标记 app 级 bus 是否已订阅,防止重复叠加
|
||||
_busSubscribed: false,
|
||||
|
||||
/**
|
||||
* 注销全局 bus 事件监听(重置订阅标志,下次 registerBusListeners 时重新订阅)
|
||||
*/
|
||||
unregisterBusListeners() {
|
||||
this._busSubscribed = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 注册全局 bus 事件监听(connectState / syncDeviceTimeSuccess / deviceWillDisconnect)
|
||||
* 通过标志位防止多次 onShow 导致回调叠加(SDK bus 不支持 unsubscribe)
|
||||
* 依赖 Blue.stop() 清空订阅,onShow 时直接调用,无需标志位
|
||||
*/
|
||||
registerBusListeners() {
|
||||
if (this._busSubscribed) return;
|
||||
this._busSubscribed = true;
|
||||
const plugin = this.globalData.ppScale.plugin;
|
||||
|
||||
// 蓝牙连接状态监听
|
||||
|
||||
Reference in New Issue
Block a user