{"id":22745508,"url":"https://github.com/aws-amplify/amplify-swift","last_synced_at":"2026-04-22T02:03:46.497Z","repository":{"id":37270593,"uuid":"177009496","full_name":"aws-amplify/amplify-swift","owner":"aws-amplify","description":"A declarative library for application development using cloud services.","archived":false,"fork":false,"pushed_at":"2025-03-24T20:13:49.000Z","size":112573,"stargazers_count":490,"open_issues_count":123,"forks_count":208,"subscribers_count":54,"default_branch":"main","last_synced_at":"2025-04-03T03:33:10.050Z","etag":null,"topics":["aws","aws-amplify","ios","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aws-amplify.png","metadata":{"files":{"readme":"README-combine-support.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-21T19:16:08.000Z","updated_at":"2025-03-28T20:15:27.000Z","dependencies_parsed_at":"2023-09-14T22:59:49.650Z","dependency_job_id":"579a6e79-430e-4bb6-8eba-212c6c4d845a","html_url":"https://github.com/aws-amplify/amplify-swift","commit_stats":{"total_commits":2173,"total_committers":56,"mean_commits":38.80357142857143,"dds":0.8481362172112288,"last_synced_commit":"ad538164c62c47670499a58e63552c14006c50c3"},"previous_names":["aws-amplify/amplify-ios"],"tags_count":998,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-amplify%2Famplify-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-amplify%2Famplify-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-amplify%2Famplify-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-amplify%2Famplify-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aws-amplify","download_url":"https://codeload.github.com/aws-amplify/amplify-swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166853,"owners_count":21058481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-amplify","ios","swift"],"created_at":"2024-12-11T02:06:49.390Z","updated_at":"2025-12-11T23:01:40.742Z","avatar_url":"https://github.com/aws-amplify.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Combine support in Amplify\n\n\u003cimg src=\"https://s3.amazonaws.com/aws-mobile-hub-images/aws-amplify-logo.png\" alt=\"AWS Amplify\" width=\"550\" \u003e\n\nAmplify supports iOS 13+ and macOS 12+, and ships with APIs that leverage Swift Concurrency (async/await) to return values. For example, the following returns an array of type `Geo.Place` with search results for coffee shops.\n\n```swift\nlet places = try await Amplify.Geo.search(for \"coffee\")\n```\n\nSome APIs do not return a simple result, such as those that return subscriptions or provide progress updates. In cases where multiple values are expected over time, Amplify typically provides an `AmplifyAsyncSequence` or `AmplifyAsyncThrowingSequence`. These types conform to the `AsyncSequence` protocol and can be iterated over asynchronously. For example, the following subscribes to the creation of new Todos.\n\n```swift\nlet subscription = Amplify.API.subscribe(\n    request: .subscription(of: Todo.self, type: .onCreate)\n)\n```\n\n## Amplify.Publisher\n\nIn order to support Combine, Amplify includes Amplify.Publisher, which can be used to get Combine Publishers for Amplify APIs, such as those listed above. Specifically, it provides static methods to create Combine Publishers from Tasks and AsyncSequences.\n\nThe following examples show how to create Combine Publishers for the above API calls.\n\n```swift\nlet sink = Amplify.Publisher.create {\n    try await Amplify.Geo.search(for \"coffee\")\n}\n    .sink { completion in\n        // handle completion\n    } receiveValue: { value in\n        // handle value\n    }\n```\n\n```swift\nlet subscription = Amplify.API.subscribe(\n    request: .subscription(of: Todo.self, type: .onCreate)\n)\n\nlet sink = Amplify.Publisher.create(subscription)\n    .sink { completion in\n        // handle completion\n    } receiveValue: { value in\n        // handle value\n    }\n```\n\n\n#### Cancellation\n\nWhen using Amplify.Publisher, cancelling a subscription to a publisher also cancels the underlying task. Note, however, that in the case of progress sequences, this would only cancel progress updates, and not the associated task such as a file upload or download. Those associated tasks would need to be cancelled separately, either by calling `.cancel()` on the task itself or by cancelling the parent task.\n\n## Hub.publisher(for:)\n\nThe Amplify Hub category exposes only one Combine-related API: `Hub.publisher(for:)`, which returns a publisher for all events on a given channel. You can then apply the standard Combine [`filter`](https://developer.apple.com/documentation/combine/anypublisher/filter(_:)) operator to inspect only those events you care about.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-amplify%2Famplify-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faws-amplify%2Famplify-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-amplify%2Famplify-swift/lists"}