Closed curioustechizen closed 7 months ago
Good question. You're right in that they're both meant to be asynchronous stream of values. That said, there is a difference in the way you read/write the code, and how each of them is started. Async/await syntax reads great, specially when you need to send commands and wait for them to finish. However, this doesn't work for all interactions because you don't always initiate them (e.g. when Bluetooth device has disconnected). In general for this library my rule of thumb is: when the developer initiates the command, you use async/await. Otherwise you use Combine's publishers.
I see that
scanForPeripherals
returns anAsyncStream
whileeventPublisher
returnsAnyPublisher
which is part of theCombine
framework. Both these data types represent an asynchronous stream of values.Is there a reason for this difference? Are there differences in capabilities between these two data types?