I'm getting used to structs
over classes
in Swift, but have a concern about best practices if I'm possibly generating retain cycles due to closures not having [unowned self]
or [weak self]
? (which isn't allowed in a struct or protocol). And the fact that I'm making all static funcs
.
struct OrgAPIservice {
static func getOrganizations(sinceSyncToken: ...
completion:@escaping (_ orgsList: [Organization]?, _ error: AppError?) -> Void) {
apiProvider.request(.getOrganizations(...)) { result in
switch result {
case .success(let response):
case .failure(let error):
completion (nil, getAppErrorFromMoya(with: error))
}
}
}
}