{"id":28417352,"url":"https://github.com/danielctull/publisherview","last_synced_at":"2025-10-07T06:56:06.510Z","repository":{"id":63907423,"uuid":"239373125","full_name":"danielctull/PublisherView","owner":"danielctull","description":"A SwiftUI view that subscribes to a Combine publisher to display different views for the values and failure of the publisher.","archived":false,"fork":false,"pushed_at":"2020-08-23T20:48:03.000Z","size":12,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-29T08:48:32.073Z","etag":null,"topics":["combine","swift","swift-package","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielctull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-09T20:57:18.000Z","updated_at":"2022-11-14T16:42:46.000Z","dependencies_parsed_at":"2022-11-28T20:15:49.237Z","dependency_job_id":null,"html_url":"https://github.com/danielctull/PublisherView","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/danielctull/PublisherView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielctull%2FPublisherView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielctull%2FPublisherView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielctull%2FPublisherView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielctull%2FPublisherView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielctull","download_url":"https://codeload.github.com/danielctull/PublisherView/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielctull%2FPublisherView/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278734410,"owners_count":26036404,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["combine","swift","swift-package","swiftui"],"created_at":"2025-06-04T05:12:37.721Z","updated_at":"2025-10-07T06:56:06.482Z","avatar_url":"https://github.com/danielctull.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PublisherView\n\n[![Latest release][release shield]][releases] [![Swift 5.1][swift shield]][swift] ![Platforms: iOS, macOS, tvOS, watchOS][platforms shield]\n\nA SwiftUI view that subscribes to a Combine publisher to show different views for values and failures.\n\n## Usage\n\nThis can be used with a data task publisher which then decodes the data into model objects. In this example We display a list of posts when they are received or show the error message on screen if the task fails.\n\n```swift\nstruct PostsView: View {\n  // Get this publisher from somewhere, maybe a data task publisher\n  let publisher: AnyPublisher\u003c[Post], Error\u003e\n  var body: some View {\n    PublisherView(publisher: publisher,\n                  initial: LoadingView.init,\n                  output: Content.init,\n                  failure: FailureView.init)\n  }\n}\n\nextension PostsView {\n\n  fileprivate struct Content: View {\n    let posts: [Post]\n    var body: some View {\n      List(posts) { post in\n        Text(post.title)\n      }\n    }\n  }\n}\n\nstruct LoadingView: View {\n  var body: some View {\n    // Some awesome loading view\n  }\n}\n\nstruct FailureView: View {\n  let error: Error\n  var body: some View {\n    Text(error.localizedDescription)\n  }\n}\n```\n\n[releases]: https://github.com/danielctull/PublisherView/releases\n[release shield]: https://img.shields.io/github/v/release/danielctull/PublisherView\n[swift]: https://swift.org\n[swift shield]: https://img.shields.io/badge/swift-5.1-F05138.svg \"Swift 5.1\"\n[platforms shield]: https://img.shields.io/badge/platforms-iOS_macOS_tvOS_watchOS-lightgrey.svg?style=flat \"iOS, macOS, tvOS, watchOS\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielctull%2Fpublisherview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielctull%2Fpublisherview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielctull%2Fpublisherview/lists"}