-
Notifications
You must be signed in to change notification settings - Fork 609
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
Fix success return type #1015
Fix success return type #1015
Conversation
Hi @MaximBelov , Are you able to provide any context for this change? I understand that you've added a bool return to Can you please provide an example of the issue you're addressing by this modification? |
Hi @peitschie I use wrapper for convenience and I will show you an example of TS code const result = await this.bluetoothLowEnergy.isConnected(device.id).catch((error) => { console.error(error); return false});
// with my changes
const connectionStatus = result ? 'connected' : 'disconnected';
// current implementation
const connectionStatus = result === 'OK' ? 'connected' : 'disconnected'; const isEnabled = await this.bluetoothLowEnergy.isEnabled();
if (isEnabled) {
this.bluetoothLowEnergy.startScan([]).subscribe({
next: (config: BluetoothBLEConnectionConfig) => {},
error: async (_error) => {},
});
} Some time ago, I had a similar issue with urbanairship plugin |
Right... I can appreciate the confusion a bit there! The default implementation of If you're wanting to turn this into a bool return, you can handle this in your wrapping code by adding a const result = await this.bluetoothLowEnergy.isConnected(device.id).then(() => true).catch((error) => { console.error(error); return false}); I don't have anything against the approach you've implemented, and certainly appreciate you taking the effort to raise this merge request, but it's not a change I want to make as it affects the interface and type definitions for these methods. I'll update the I repeat again though, thanks for your contribution efforts here! I'll close this out and raise the documentation improvements in preference. |
Related to discussion on #1015
Related to discussion on #1015
Writing the documentation gave me a hint as to how to better support the use-case you've got here, without introducing any backwards compatibility changes. I've introduced an overload of With this tweak, you should now be able to write the above as: // Promises with boolean return
const isConnected = await ble.withPromises.isConnected(device_id, false); Let me know if you're happy with this approach, and I'll cut it into a full release! |
Related to discussion on #1015
Related to discussion on #1015
No description provided.