Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE.autoconnect #2573

Closed
don opened this issue Jun 29, 2018 · 1 comment · Fixed by #2594
Closed

BLE.autoconnect #2573

don opened this issue Jun 29, 2018 · 1 comment · Fixed by #2594

Comments

@don
Copy link
Contributor

don commented Jun 29, 2018

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior:
BLE.autoConnect returns an Observable which only works on time. The for Cordova, connect/success and disconnect/failure functions are called multiple times. With an Observable the disconnect function can only be called 1x.

https://github.com/ionic-team/ionic-native/blob/master/src/%40ionic-native/plugins/ble/index.ts#L306-L313

Expected behavior:
BLE.autoconnect needs to return callbacks. I think the right way to do this is to wrap as a sync function and use the callbacks directly?

Other information:
Do any other plugins have callbacks that are called many times? It'd be nice if the behavior here matched other Ionic plugins.

I'll send a pull request to fix this once I figure out the right way to do this.

@don
Copy link
Contributor Author

don commented Jul 2, 2018

My current fix for this uses @Cordova({ sync: true }) which provides access to the callbacks from Ionic. It works but the user needs to bind the callbacks to this, which isn't ideal.

this.ble.autoConnect(MAC_ADDRESS, this.onConnected.bind(this), this.onDisconnected.bind(this));

@danielsogl @ihadeed @mhartington is there any way to have the Cordova wrapper bind callbacks for the user?

don added a commit to don/ionic-native that referenced this issue Jul 11, 2018
danielsogl pushed a commit that referenced this issue Jul 13, 2018
* fix(ble): change signature for autoConnect (#2573)

* fix(ble): update usage for autoConnect (#2573)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant