【发布时间】:2017-08-30 12:14:50
【问题描述】:
我正在使用 cordova 的 BLE(低功耗蓝牙)
订阅 BLE 的通知(返回 Observable)后,我想向 ble 设备发送一些消息,执行此操作的最佳方法是什么,基本上我需要在订阅后运行一次函数所以一旦设备回复我,订阅中的代码就会运行。
ble.startNotification(deviceId, uuid1, uuid2).subscribe(bufferData=> {
//do something with bufferData
})
在这之后,我想运行类似回调的东西,
.then(()=> {
//send message to device (only once), after the message is sent, the device will respond back and the `do something with bufferData` code will be run
})
我可以轻松地做一个setTimeout 并在几秒钟后向设备发送一条消息,当然它可以工作,但我想干净地做到这一点,在我确定订阅发生之后(订阅 Observable当然)
【问题讨论】:
标签: ionic-framework rxjs