fiskaly / fiskaly-sdk-swift

fiskaly Cloud-TSE SDK for Swift/iOS
MIT License
5 stars 5 forks source link

Network requests are being performed synchronously #7

Closed marcelvoss closed 4 years ago

marcelvoss commented 4 years ago

Hi there,

as my team @sumup is currently looking at integrating this SDK, I went through the code base and noticed that all network requests are being performed in a synchronous manner, essentially blocking the main thread for the duration of the request.

While the call to the Fiskaly SDK can be dispatched to a background thread by the integrators, this is something the SDK should do itself and also utilize the same queue for JSON decoding. It doesn't make a lot of sense when each integrator has to dispatch themselves while the SDK could easily hide it itself and dispatch back to the main thread after everything is done, keeping a standardized behavior for all functions.

This also goes hand-in-hand with replacing the throwing from these function calls with proper using of Swift.Result and wrapping both JsonRpcErrors and Swift.Errorobjects into a single Result type.

Thanks!