I need to change a part of github library code. Below function is for searching bluetooth devices. The problem is, this function will return devices when all task is finished. As you know, if you do searching bluetooth, connectable devices appear one by one, not at once.
startDiscovery() {
return __awaiter(this, void 0, void 0, function* () {
let discoveredDevices = yield this._nativeModule.startDiscovery();
for (let discovered of discoveredDevices) {
devices.push(new BluetoothDevice(discovered, this));
}
return devices;
});
}
Current Behavior
const devices = await startDiscovery()
setDevices(devices) // update 10 devices at once - annoying.
What I wish
startDiscovery((newDevice) => {
if(newDevice) setDevices([...devices, newDevice])
// it would update devices one by one, smoothly.
})
Is it possible to change startDiscovery
function?