{"id":25829373,"url":"https://github.com/matis-schotte/publishedkvo","last_synced_at":"2026-05-11T01:14:23.338Z","repository":{"id":40700987,"uuid":"269921737","full_name":"matis-schotte/PublishedKVO","owner":"matis-schotte","description":"PublishedKVO provides Apples Combine `@Published` for class-types using Key-Value-Observing (KVO requires classes to be NSObject-based).","archived":false,"fork":false,"pushed_at":"2022-07-06T04:35:07.000Z","size":19,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-23T05:45:59.787Z","etag":null,"topics":["class","combine","ios","key-value-observing","kvo","macos","module","nsobject","package","published","publisher","swift","tvos","watchos","xcode"],"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/matis-schotte.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-06-06T08:44:24.000Z","updated_at":"2021-01-12T14:56:22.000Z","dependencies_parsed_at":"2022-09-23T07:30:21.505Z","dependency_job_id":null,"html_url":"https://github.com/matis-schotte/PublishedKVO","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matis-schotte%2FPublishedKVO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matis-schotte%2FPublishedKVO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matis-schotte%2FPublishedKVO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matis-schotte%2FPublishedKVO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matis-schotte","download_url":"https://codeload.github.com/matis-schotte/PublishedKVO/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241205761,"owners_count":19927144,"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":["class","combine","ios","key-value-observing","kvo","macos","module","nsobject","package","published","publisher","swift","tvos","watchos","xcode"],"created_at":"2025-02-28T18:58:08.589Z","updated_at":"2026-05-11T01:14:23.267Z","avatar_url":"https://github.com/matis-schotte.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PublishedKVO\n\n![build](https://img.shields.io/badge/build-passing-success)\n![tests](https://img.shields.io/badge/tests-passing-success)\n![language](https://img.shields.io/badge/language-swift-important)\n[![license](https://img.shields.io/github/license/matis-schotte/PublishedKVO.svg)](./LICENSE)\n\n![platform](https://img.shields.io/badge/platform-iOS%20|%20macOS%20|%20tvOS%20|%20watchOS-lightgrey.svg)\n[![Twitter](https://img.shields.io/badge/twitter-@matis_schotte-blue.svg)](http://twitter.com/matis_schotte)\n\n![Ethereum](https://img.shields.io/badge/ethereum-0x25C93954ad65f1Bb5A1fd70Ec33f3b9fe72e5e58-yellowgreen.svg)\n![Litecoin](https://img.shields.io/badge/litecoin-MPech47X9GjaatuV4sQsEzoMwGMxKzdXaH-lightgrey.svg)\n\nPublishedKVO provides Apples Combine `@Published` for class-types using Key-Value-Observing (KVO requires classes to be NSObject-based).\n`@PublishedKVO`  automatically publishes objects based on one or mutliple key paths.\nAttention: When using with SwiftUI unexpected results may occur since this publisher usually emits values _after_\nthey are set inside the object (and _before_ if the variable is overwritten/re-assigned), not always before as with the\nstructs willSet-based `@Published` - this is mostly related to SwiftUIs diffing and/or animation features, probably.\n\n## Requirements\n- Swift \u003e= 5\n- iOS \u003e= 13\n- macOS \u003e= 10.15\n- tvOS \u003e= 13\n- watchOS \u003e= 6\n\n## Installation\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.\n\nAdd the Package URL `https://github.com/matis-schotte/PublishedKVO.git` in Xcodes project viewer.\nAdding it to another Package as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n\t.package(url: \"https://github.com/matis-schotte/PublishedKVO.git\", from: \"0.1.0\")\n]\n```\n\n## Usage\n\n```swift\nclass Example {\n\t@PublishedKVO(\\.completedUnitCount)\n\tvar progress = Progress(totalUnitCount: 2)\n\t\n\t@Published\n\tvar textualRepresentation = \"text\"\n}\n\nlet ex = Example()\n\n// Set up the publishers\nlet c1 = ex.$progress.sink { print(\"\\($0.fractionCompleted) completed\") }\nlet c1 = ex.$textualRepresentation.sink { print(\"\\($0)\") }\n\n// Interact with the class as usual\nex.progress.completedUnitCount += 1\n// outputs \"0.5 completed\"\n\n// And compare with Combines @Published (almost°) same behaviour\nex.textualRepresentation = \"string\"\n// outputs \"string\"\n\nex.$progress.emit() // Re-emits the current value\nex.$progress.send(ex.progress) // Emits given value\n```\n\n° See `Attention` comment from above about SwiftUI and the following example:\n\n```swift\nclass Example {\n\t@PublishedKVO(\\.completedUnitCount)\n\tvar progress1 = Progress(totalUnitCount: 5)\n\t\n\t@Published\n\tvar progress2 = Progress(totalUnitCount: 5)\n\t\n\t@Published\n\tvar progress3 = \"0.0\"\n}\n\nlet ex = Example()\n\n// Class using @PublishedKVO\nlet c1 = ex.$progress1.sink { print(\"$progress1 incomming \\($0.fractionCompleted) actual \\(ex.progress1.fractionCompleted)\") }\n// Class using @Published\nlet c2 = ex.$progress2.sink { print(\"$progress2 incomming \\($0.fractionCompleted) actual \\(ex.progress2.fractionCompleted)\") }\n// Struct using @Published\nlet c3 = ex.$progress3.sink { print(\"$progress3 incomming \\($0) actual \\(ex.progress3)\") }\n\nex.progress1.completedUnitCount += 1\nex.progress2.completedUnitCount += 1\nex.progress3 = \"0.2\"\n\nex.progress1.completedUnitCount += 1\nex.progress2.completedUnitCount += 1\nex.progress3 = \"0.4\"\n\n/* Outputs (incomming should new value, actual should be old value):\n$progress1 incomming 0.0 actual 0.0\n$progress2 incomming 0.0 actual 0.0\n$progress3 incomming 0.0 actual 0.0\n\n$progress1 incomming 0.2 actual 0.2\n// no output from $progress2\n$progress3 incomming 0.2 actual 0.0\n\n$progress1 incomming 0.4 actual 0.4\n// no output from $progress2\n$progress3 incomming 0.4 actual 0.2\n*/\n```\n\n[//]: # (Example: See the example project inside the `examples/` folder.)\n\n## ToDo\n- Add SwiftLint (by adding xcodeproj: `swift package generate-xcodeproj`, helps support Xcode Server, too)\n- Add Travis CI (without xcodeproj see [reddit](https://www.reddit.com/r/iOSProgramming/comments/d7oyvh/configure_travis_ci_on_github_to_build_ios_swift/), [medium](https://medium.com/@aclaytonscott/creating-and-distributing-swift-packages-132444f5dd1))\n- Add codecov\n- Add codebeat\n- Add codeclimate\n- Add codetriage\n- Add jazzy docs\n- Add CHANGELOG.md\n- Add Carthage support\n- Add Cocoapods support\n\n[//]: # (Donations: ETH, LTC welcome.)\n\n## License\nPublishedKVO is available under the Apache-2.0 license. See the [LICENSE](https://github.com/matis-schotte/PublishedKVO/blob/master/LICENSE) file for more info.\n\n## Author\nMatis Schotte, [dm26f1cab8aa26@ungeord.net](mailto:dm26f1cab8aa26@ungeord.net)\n\n[https://github.com/matis-schotte/PublishedKVO](https://github.com/matis-schotte/PublishedKVO)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatis-schotte%2Fpublishedkvo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatis-schotte%2Fpublishedkvo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatis-schotte%2Fpublishedkvo/lists"}