Use idiomatic asynchronous dispatch to avoid blocking the main CPU thread
Todos:
[x] Utilities does not inherit from SafariExtensionHandler
[x] Class uses class functions (debatable)
[x] Refactor Utilities.request method to take a closure that will resolve the Result type
[x] Rename RequestErrors => RequestError
[x] Add undefined to RequestError
[x] Refactor API.validateAuthCode to take a closure that will resolve the Result type
[x] Refactor API.getGuid to take a closure that will resolve the Result type
Implementation Decisions
The refactor of API.request makes it consistent with idiomatic Swift (insomuch as I know anything about Swift). In the API.validateAuthCode function, I created an example of how one can use a dedicated dispatch queue to use dispatch semaphores without blocking the main queue.
All Submissions:
[x] Have you followed the guidelines in our Contributing document?
[x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
Goal
Use idiomatic asynchronous dispatch to avoid blocking the main CPU thread
Todos:
Utilities
does not inherit fromSafariExtensionHandler
Class
usesclass
functions (debatable)Utilities.request
method to take a closure that will resolve theResult
typeRequestErrors
=>RequestError
undefined
toRequestError
API.validateAuthCode
to take a closure that will resolve theResult
typeAPI.getGuid
to take a closure that will resolve theResult
typeImplementation Decisions
The refactor of
API.request
makes it consistent with idiomatic Swift (insomuch as I know anything about Swift). In theAPI.validateAuthCode
function, I created an example of how one can use a dedicated dispatch queue to use dispatch semaphores without blocking the main queue.All Submissions: