react-native-ble-manager icon indicating copy to clipboard operation
react-native-ble-manager copied to clipboard

Improve Events (or update Docs)

Open JThobbyist opened this issue 3 years ago • 2 comments

Events should be listenable directly on the BleManager instance. The docs show something like

import { NativeModules, NativeEventEmitter } from 'react-native';
BleManagerEventEmitter = new NativeEventEmitter(BleManagerModule);

This should be included out-of-the-box by adding the above 'import' statement as well as the following class-edits to BleManage.js:

class BleManager extends NativeEventEmitter {
constructor(){
super(BleManagerModule);
...
}
...
}```

And if this is already the case that BleManager exposes events itself, then the docs should be updated (but it doesn't look like it does based on inspection of the code)

JThobbyist avatar Apr 16 '22 18:04 JThobbyist

Hi, I made the example like the official doc, why are you suggesting to do it in another way?

marcosinigaglia avatar Jul 25 '22 10:07 marcosinigaglia

Hi Marco,

I am suggesting to do it another way because the official doc example is a use-case where you can choose if you want the eventemitter or not. This choice works well for use-cases where the eventemitter is not required for the module to function in a useful way.

The react-native-ble-manager module relies directly on the events, and would not work without them. As it currently is, the module forces every user to repeat the code from the example in the docs in order to use the module.

Therefore, my suggestion is to streamline the user experience by incorporating the example from the docs “under the hood” within the module. This way, users don’t need to repeat it, and can simply listen for events on the module itself.

Please let me know your thoughts?

Best, -Joe

On Jul 25, 2022, at 6:04 AM, Marco Sinigaglia @.***> wrote:

 Hi, I made the example like the official doc, why are you suggesting to do it in another way?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

JThobbyist avatar Jul 25 '22 12:07 JThobbyist