{"id":17242477,"url":"https://github.com/groue/combinetraits","last_synced_at":"2025-04-14T03:25:06.544Z","repository":{"id":49099504,"uuid":"300177981","full_name":"groue/CombineTraits","owner":"groue","description":"Combine Publishers with Guarantees","archived":false,"fork":false,"pushed_at":"2023-09-12T11:15:46.000Z","size":219,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T17:22:39.242Z","etag":null,"topics":["combine"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/groue.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-01T06:54:29.000Z","updated_at":"2025-02-18T14:24:39.000Z","dependencies_parsed_at":"2022-09-08T15:12:02.818Z","dependency_job_id":null,"html_url":"https://github.com/groue/CombineTraits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groue%2FCombineTraits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groue%2FCombineTraits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groue%2FCombineTraits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groue%2FCombineTraits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/groue","download_url":"https://codeload.github.com/groue/CombineTraits/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248814554,"owners_count":21165783,"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":["combine"],"created_at":"2024-10-15T06:13:21.642Z","updated_at":"2025-04-14T03:25:06.526Z","avatar_url":"https://github.com/groue.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"CombineTraits [![Swift 5.8](https://img.shields.io/badge/swift-5.8-orange.svg?style=flat)](https://developer.apple.com/swift/)\n=============\n\n### Combine Publishers with Guarantees\n\n**Requirements**: iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ \u0026bull; Swift 5.8+ / Xcode 14.3+\n\n---\n\n## What is this?\n\n[Combine] publishers can publish any number of values, at any time, before they complete. It is particularly the case of [AnyPublisher], frequently returned by our frameworks or applications.\n\nWhen we deal with publishers that are expected to publish their values according to a specific pattern, it is easy to neglect edge cases such as late publishing, early completion, too many published values, etc. And quite often, the behavior of such publishers is subject to interpretation, imprecise documentation, or buggy implementations.\n\nThis library provides compiler-checked definition, and subscription, to publishers that conform to specific *traits*:\n        \n- **[Single Publishers]** publish exactly one value, or an error.\n    \n    The Combine `Just`, `Future` and `URLSession.DataTaskPublisher` are examples of such publishers.\n    \n    ```\n    --------\u003e can never publish anything, never complete.\n    -----x--\u003e can fail before publishing any value.\n    --o--|--\u003e can publish one value and complete.\n    ```\n    \n- **[Maybe Publishers]** publish exactly zero value, or one value, or an error:\n    \n    The Combine `Empty`, `Just`, `Future` and `URLSession.DataTaskPublisher` are examples of such publishers.\n    \n    ```\n    --------\u003e can never publish anything, never complete.\n    -----x--\u003e can fail before publishing any value.\n    -----|--\u003e can complete without publishing any value.\n    --o--|--\u003e can publish one value and complete.\n    ```\n    \n- **[Immediate Publishers]** publish a value or fail, right on subscription:\n    \n    The Combine `Just` and `Fail` are examples of such publishers.\n    \n    ```\n    x-------\u003e can fail immediately.\n    o - - - \u003e can publish one value immediately (and then publish any number\n              of values, at any time, until the eventual completion).\n    ```\n\n# Documentation\n\n- [Usage]\n- [Single Publishers]\n- [Maybe Publishers]\n- [Immediate Publishers]\n\n**Derived Tools**\n\n- [Trait Operators]\n- [SinglePublisherOperation]\n- [TraitPublishers.AsOperation]\n- [TraitPublishers.Maybe]\n- [TraitPublishers.PreventCancellation]\n- [TraitPublishers.Single]\n- [TraitPublishers.ZipSingle]\n- [TraitSubscriptions.Maybe]\n- [TraitSubscriptions.Single]\n\n## Usage\n\n**CombineTraits preserves the general ergonomics of Combine.** Your application still deals with regular Combine publishers and operators.\n\n`AnyPublisher` can be replaced with `AnySinglePublisher`, `AnyMaybePublisher`, or `AnyImmediatePublisher`, in order to express which trait a publisher conforms to:\n    \n```swift\nfunc refreshPublisher() -\u003e AnySinglePublisher\u003cVoid, Error\u003e {\n    downloadPublisher()\n        .map { apiModel in Model(apiModel) }\n        .flatMap { model in savePublisher(model) }\n        .eraseToAnySinglePublisher()\n}\n```\n\nOn the consumption side, `sink` can be replaced with `sinkSingle` or `sinkMaybe`, for easier handling of a given publisher trait:\n    \n```swift\nlet cancellable = refreshPublisher().sinkSingle { result in\n    switch result {\n    case .success: ...\n    case let .failure(error): ...\n    }\n}\n```\n\n[AnyPublisher]: https://developer.apple.com/documentation/combine/anypublisher\n[Combine]: https://developer.apple.com/documentation/combine\n[Release Notes]: CHANGELOG.md\n[Usage]: #usage\n[Single Publishers]: Documentation/SinglePublisher.md\n[Maybe Publishers]: Documentation/MaybePublisher.md\n[Immediate Publishers]: Documentation/ImmediatePublisher.md\n[Trait Operators]: Documentation/Operators.md\n[SinglePublisherOperation]: Documentation/SinglePublisherOperation.md\n[TraitPublishers.AsOperation]: Documentation/TraitPublishers-AsOperation.md\n[TraitPublishers.Maybe]: Documentation/TraitPublishers-Maybe.md\n[TraitPublishers.PreventCancellation]: Documentation/TraitPublishers-PreventCancellation.md\n[TraitPublishers.Single]: Documentation/TraitPublishers-Single.md\n[TraitPublishers.ZipSingle]: Documentation/TraitPublishers-ZipSingle.md\n[TraitSubscriptions.Maybe]: Documentation/TraitSubscriptions-Maybe.md\n[TraitSubscriptions.Single]: Documentation/TraitSubscriptions-Single.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgroue%2Fcombinetraits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgroue%2Fcombinetraits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgroue%2Fcombinetraits/lists"}