Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacobsapps/723f61929638039164b76fe80464f934 to your computer and use it in GitHub Desktop.
Save jacobsapps/723f61929638039164b76fe80464f934 to your computer and use it in GitHub Desktop.
final class ContactsService {
let userAPI = UserAPI()
private(set) var contacts = [Contact]()
private let contactsActor = TaskActor<[Contact]>()
func fetchContacts() async throws {
contacts = try await contactsActor.run { [weak self] in
try await self?.userAPI.fetchAllUsersInContacts() ?? []
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment