{"action":"created","issue":{"url":"https://api.github.com/repos/don/BluetoothSerial/issues/364","repository_url":"https://api.github.com/repos/don/BluetoothSerial","labels_url":"https://api.github.com/repos/don/BluetoothSerial/issues/364/labels{/name}","comments_url":"https://api.github.com/repos/don/BluetoothSerial/issues/364/comments","events_url":"https://api.github.com/repos/don/BluetoothSerial/issues/364/events","html_url":"https://github.com/don/BluetoothSerial/issues/364","id":321144978,"number":364,"title":"Issue with Connect returned observable in Ionic 3.","user":{"login":"vivekmuthu1910","id":24466675,"avatar_url":"https://avatars0.githubusercontent.com/u/24466675?v=4","gravatar_id":"","url":"https://api.github.com/users/vivekmuthu1910","html_url":"https://github.com/vivekmuthu1910","followers_url":"https://api.github.com/users/vivekmuthu1910/followers","following_url":"https://api.github.com/users/vivekmuthu1910/following{/other_user}","gists_url":"https://api.github.com/users/vivekmuthu1910/gists{/gist_id}","starred_url":"https://api.github.com/users/vivekmuthu1910/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vivekmuthu1910/subscriptions","organizations_url":"https://api.github.com/users/vivekmuthu1910/orgs","repos_url":"https://api.github.com/users/vivekmuthu1910/repos","events_url":"https://api.github.com/users/vivekmuthu1910/events{/privacy}","received_events_url":"https://api.github.com/users/vivekmuthu1910/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-08T11:19:17Z","updated_at":"2018-05-19T08:12:24Z","closed_at":null,"author_association":"NONE","body":"This is the code I am running in android device using `ionic cordova run android --device` cli command.\r\n\r\n```typescript\r\nimport { Component } from '@angular/core';\r\nimport { IonicPage } from 'ionic-angular';\r\nimport { BluetoothSerial } from '@ionic-native/bluetooth-serial';\r\n\r\ninterface pairedDevice{\r\n  name: string,\r\n  address: string,\r\n  id: string,\r\n  class: number\r\n}\r\n\r\n@IonicPage()\r\n@Component({\r\n  selector: 'page-devices',\r\n  template: `\r\n<ion-content padding>\r\n  <button ion-button block (click)=\"listPairedDevices()\">List all Paired Devices</button>\r\n  <button ion-button (click)=\"connect(device)\" *ngFor=\"let device of pairedDevices\">{{device.name}}</button><br />\r\n  <button ion-button *ngIf=\"connectStatus\" (click)=\"send('1')\">On</button>\r\n</ion-content>\r\n`,\r\n})\r\n\r\nexport class DevicesPage {\r\n  public connectStatus = false;\r\n  public pairedDevices: Array<pairedDevice>;\r\n\r\n  constructor(private bluetoothSerial: BluetoothSerial) {\r\n  }\r\n  listPairedDevices(){\r\n    this.bluetoothSerial.list().then((list)=>this.pairedDevices=list);\r\n  }\r\n  send(num: string){\r\n    this.bluetoothSerial.write(num);\r\n  }\r\n  connect(device: pairedDevice){\r\n    this.bluetoothSerial.connect(device.address).subscribe(\r\n      ()=>{\r\n        this.connectStatus=true;\r\n      },\r\n      ()=>{\r\n        this.connectStatus=false;\r\n      });\r\n  }\r\n}\r\n\r\n```\r\nWhen I list the paired devices, it is listing the devices. I tried to connect it with HC-05 module. When I click connect the device is connecting, but the subscribed function doesn't get called until some other event happens (like locking and unlocking the mobile, or clicking list paired devices etc.).\r\n\r\nCan anyone please guide me through this.\r\n\r\nEven `bluetoothSerial.write(num)` is also working. I tested it by removing the `*ngIf`. \r\nOnly the subscribe functions `this.connectStatus=true;` and `this.connectStatus=false;` doesn't get executed until some other interaction happens."},"comment":{"url":"https://api.github.com/repos/don/BluetoothSerial/issues/comments/390388474","html_url":"https://github.com/don/BluetoothSerial/issues/364#issuecomment-390388474","issue_url":"https://api.github.com/repos/don/BluetoothSerial/issues/364","id":390388474,"user":{"login":"vivekmuthu1910","id":24466675,"avatar_url":"https://avatars0.githubusercontent.com/u/24466675?v=4","gravatar_id":"","url":"https://api.github.com/users/vivekmuthu1910","html_url":"https://github.com/vivekmuthu1910","followers_url":"https://api.github.com/users/vivekmuthu1910/followers","following_url":"https://api.github.com/users/vivekmuthu1910/following{/other_user}","gists_url":"https://api.github.com/users/vivekmuthu1910/gists{/gist_id}","starred_url":"https://api.github.com/users/vivekmuthu1910/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vivekmuthu1910/subscriptions","organizations_url":"https://api.github.com/users/vivekmuthu1910/orgs","repos_url":"https://api.github.com/users/vivekmuthu1910/repos","events_url":"https://api.github.com/users/vivekmuthu1910/events{/privacy}","received_events_url":"https://api.github.com/users/vivekmuthu1910/received_events","type":"User","site_admin":false},"created_at":"2018-05-19T08:12:24Z","updated_at":"2018-05-19T08:12:24Z","author_association":"NONE","body":"Thank you @fiyi. The alert is working.\r\nI was able to use ngZone to fix the UI update in async mode."}}
{"actor":{"display_login":"vivekmuthu1910"}}