You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normally, the UI will have some spinner or a loading indicator to show the fact that the request is being sent and the UI is being updated. This is even more important in case of non-GET requests, such as POST which might modify the resource. The UI should be blocked while the operation is ongoing.
One way to accomplish this is to use a defer construct:
func getNewInfo(){defer{ isInProgress =false}
isInProgress =true
client.myInfo()...... // Process the response
}
However, this is cumbersome and error-prone, as it requires attention from the developer to add this logic around every request that's being sent with the client.
I'm asking whether this is currently available or possible to implement / consider as an idea for this project to have some sort of a state publisher set on the request itself, so that an arbitrary number of subscribers can attach to that publisher and connect their UI states directly to the result of that request.
This makes easy implementing the same scenario for multiple requests executed in parallel and enabling the UI only when all of them have been completed.
If this is actually possible right now, please let me know how I can implement this "request tracking" design in my code.
From a technical standpoint, this should be possible by leveraging the URLSessionTaskdelegate and other properties. Connecting to those properties could allow to expose the progress and the status of the request via Get's API:
Consider the following, when this library is used together with CreateAPI: https://github.com/CreateAPI/CreateAPI
Normally, the UI will have some spinner or a loading indicator to show the fact that the request is being sent and the UI is being updated. This is even more important in case of non-
GET
requests, such asPOST
which might modify the resource. The UI should be blocked while the operation is ongoing.One way to accomplish this is to use a
defer
construct:However, this is cumbersome and error-prone, as it requires attention from the developer to add this logic around every request that's being sent with the client.
I'm asking whether this is currently available or possible to implement / consider as an idea for this project to have some sort of a state publisher set on the request itself, so that an arbitrary number of subscribers can attach to that publisher and connect their UI states directly to the result of that request.
This makes easy implementing the same scenario for multiple requests executed in parallel and enabling the UI only when all of them have been completed.
If this is actually possible right now, please let me know how I can implement this "request tracking" design in my code.
From a technical standpoint, this should be possible by leveraging the
URLSessionTask
delegate
and other properties. Connecting to those properties could allow to expose the progress and the status of the request via Get's API:The text was updated successfully, but these errors were encountered: