-
Notifications
You must be signed in to change notification settings - Fork 13
Description
I am a confused about the parameter completeFn in bleat.startScan().
It says in the documentation that it is a function called if/when scanning stops. Is the idea it should be called when bleat.stopScan() is called? I am a bit confused by this.
The Evothings adapter calls completeFn as soon as scanning is started. As I recall this was needed for the Web Bluetooth API to work properly, see this discussion: #31
However, the noble adapter does not call completeFn once scanning starts, only when there is an error. Edit: I see now that the noble adapter calls completeFn in checkForError. So behaviour is the same for noble and Evothings adapters.
It would be great if the purpose of completeFn could be clarified further and then implementations be updated to follow the intended behaviour.
In my experience a common pattern when scanning is to use foundFn and errorFn, would it be possible to make the Bleat API so that completeFn is empty when two functions are given to startScan? That could be a convenient pattern. (Perhaps I am missing the whole point of completeFn, hence opening this issue.)