https://github.com/inekipelov/combine-observation-broadcast
Lightweight Swift library for hierarchical state broadcasting for ObservableObjects
https://github.com/inekipelov/combine-observation-broadcast
combine observable-object observableobject swift
Last synced: 11 months ago
JSON representation
Lightweight Swift library for hierarchical state broadcasting for ObservableObjects
- Host: GitHub
- URL: https://github.com/inekipelov/combine-observation-broadcast
- Owner: inekipelov
- License: mit
- Created: 2025-05-17T15:48:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-07T11:47:38.000Z (12 months ago)
- Last Synced: 2025-07-07T12:36:34.149Z (12 months ago)
- Topics: combine, observable-object, observableobject, swift
- Language: Swift
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CombineObservationBroadcast
[](https://swift.org/)
[](https://swift.org/package-manager/)
[](LICENSE)
[](https://github.com/inekipelov/combine-observation-broadcast/actions/workflows/swift.yml)
[](https://developer.apple.com/ios/)
[](https://developer.apple.com/macos/)
[](https://developer.apple.com/tvos/)
[](https://developer.apple.com/watchos/)
A lightweight Swift library for hierarchical state management and change propagation in SwiftUI applications using Combine and the `ObservableObject` protocol.
## Usage
```swift
import CombineObservationBroadcast
class Child: ObservableObject {
@Published var count: Int = 0
func increment() {
count += 1
}
}
class Parent: ObservableObject {
private(set) lazy var child = ObservationBroadcast(Child(), to: self)
}
let parent = Parent()
var isChanged = false
let cancellable = parent.objectWillChange
.sink { isChanged = true }
parent.child().increment()
parent.child().increment()
print(parent.child().count) // Printed "2"
print(isChanged) // Printed "true"
```
## Installation
### Swift Package Manager
Add the following to your `Package.swift` file:
```swift
dependencies: [
.package(url: "https://github.com/inekipelov/combine-observation-broadcast.git", from: "0.3.0")
]
```
Or add it directly in Xcode using File → Swift Packages → Add Package Dependency...
## License
This library is released under the MIT License. See [LICENSE](LICENSE) for details.