Is there a pattern or technique we can use for handling events in Recoil?
In Saga we could use the emit method and create stream of data.
Ive been trying to wrap my mind around how something like this can be achieved in Recoil.
For ex scanning for bluetooth connected devices.
manager.onStateChange(state => {
const enableScanning = state === State.PoweredOn
if (enableScanning) {
manager.startDeviceScan(
null,
{ allowDuplicates: false },
(error, scannedDevice) => {
if (error) {
return
}
if (scannedDevice !== null) {
//HERE WE NEED TO HANDLE THE ADDITION OF THE DEVICE TO A LIST
}
}
)
}
}, true)