Skip to content
This repository has been archived by the owner on Nov 23, 2018. It is now read-only.

initializePeripheral is broken #3

Closed
jaco-terbraak opened this issue Jun 21, 2018 · 6 comments
Closed

initializePeripheral is broken #3

jaco-terbraak opened this issue Jun 21, 2018 · 6 comments

Comments

@jaco-terbraak
Copy link
Contributor

initializePeripheral returns a Promise<{...}>, which is used as callback for any incoming data on the Gatt server. However, Promise allows invocation of the then()-callback only once, which will make it work the first time, but not for subsequent callbacks. Therefore it will trigger a callback to say that initializePeripheral succeeded, but after that the callback is never triggered again.

The fix is to change the return type in

to Observable<{...}>, which does support multiple callback invocations.

@somq
Copy link
Owner

somq commented Jun 22, 2018

I think you are right, I can't test right now though.
ref: https://github.com/randdusing/cordova-plugin-bluetoothle#initializeperipheral

It feels a bit not intuitive to me because "initialize" usually refers to a 1 time action with only 1 callback needed.

Merged your PR, thanks.

@jaco-terbraak
Copy link
Contributor Author

Thanks. I've tested this with actual hardware, and can confirm it works.

I agree that the naming is a bit misleading, I suspect it was a shortcut taken by the Cordova plugin developer.

@somq
Copy link
Owner

somq commented Jun 22, 2018

Alright, will dig into that when I'm going back to this plugin.
Thank you @jaco-terbraak

@curious-monggo
Copy link

This... this <3. You sir, are a lifesaver! Btw, it would do you good if you specify the methods available right on the readme as how randdusing does. Maaan, I almost skipped this one because I thought this doesn't support peripheral mode, All hail somq~!

@curious-monggo
Copy link

I really hope this plugin gets more support from the ionic community 👍

@somq
Copy link
Owner

somq commented Aug 22, 2018

Hi @laaaaanceeee ,
Your welcome, glad it can help!

I've just made a pull request on ionic-native repo.
danielsogl/awesome-cordova-plugins#2651

It contains any available methods and all of them are documented!
Feel free to test it.

Tomorrow I will update this repo btw

@somq somq closed this as completed Aug 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants