Closed JoshHrach closed 5 years ago
Please merge this!
@JoshHrach I tried to use your branch with Alamofire
but my request get stuck, do you know why?
It returns NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
@ppamorim It hangs while using a DispatchGroup.notify() call? Or when doing a .wait()? Because I found notify to work more reliably than wait.
I'll look at the Alamofire issue later to see if it's related.
This project has been growing a bit old and newer Swift API quite decent. So I don't want this wrapper to grow more than what it already covers.
Thanks!
While AsyncGroup currently supports calling wait(), that doesn't always work when dealing with a group. An example is trying to call a series of nested functions that eventually perform an asynchronous network call. The group seems to finish, but it appears to complete immediately, leading to no action within the async method and no actual 'waiting'. Thus, if you were performing a segue after waiting and were setting up data for the segue in the group, the segue would complete without any of the data actually being passed along.
Creating a DispatchGroup().notify call lets you wait until something is done and calling the action that needs to be done after the group is complete. For instance, you can create a group that calls various async methods within the group and trigger a segue after the group has completed its tasks.
I created this in the AsyncGroup struct. User can either call .notify(queue:) and specify the main queue, or .notify(qos:) and specify the Quality of Service, such as Utility, Background, User Initiated, etc.
This is a lot cleaner in Swift 3 than my previous (and now closed) pull request.