Ionic 2 BLE 断开连接 callback/subscribe

Ionic 2 BLE disconnect callback/subscribe

我在尝试订阅断开连接回调时收到此错误。

this.ble.disconnect(this.device_id).subscribe((data) => {
  console.log("disconnected good");
}, error => {
  console.log("disconnected bad");
});

我得到的错误是这样的

 Supplied parameters do not match any signature of call target.
 L116:  if (this.device_id) {
 L117:      this.ble.disconnect(this.device_id).subscribe((data) => {
 L118:              console.log("disconnected good");

disconnect-函数 returns 是 Promise 而不是 Observable (docs)。

试试这个:

this.ble.disconnect(this.device_id)
.then(data => {
    console.log("disconnected good");
}
.catch(error => {
    console.log("disconnected bad");
});

固定:

this.ble.disconnect(this.device_id).then(() => {
  console.log('Disconnected');
});