How dropbox/rxpublished works
Project type and purpose
• Project type: Swift Package Manager library, open-source tool.
• Purpose: Provide an @RxPublished property wrapper that plugs into SwiftUI’s ObservableObject ViewModels, replacing Combine’s @Published with RxSwift under the hood.
File structure
• Top-level:
– Package.swift (defines the Swift package, targets, dependencies)
– Sources/RxPublished/RxPublished.swift (core implementation)
– Tests/RxPublishedTests/RxPublishedTests.swift (unit tests)
• No separate “frontend” / “backend” – it’s purely a library.
• Key patterns: property-wrapper, binding to external Observables, use of RxSwift subjects/observables.
Mine the README for additional insights
• Describes usage patterns:
– Annotate view-model properties with @RxPublished
– Bind external Observable<T> to underscored accessor (_property)
– Subscribe to projected value ($property)
Main components
a. Consumer SwiftUI ViewModel
b. @RxPublished Property Wrapper (in RxPublished.swift)
c. Underlying RxSwift primitives (Subject / Observable / DisposableBag)
d. SwiftUI Binding system (reads/writes via projected value $)
e. Optional external Observable (binds into _property)
f. Test harness (unit tests target, RxPublishedTests)
Relationships and data flows
• Initialization: ViewModel declares @RxPublished var example → wrapper creates a BehaviorSubject or PublishSubject.
• Writing: setting example = newValue → wrapper pushes newValue into subject → SwiftUI views observing $example update.
• Reading: SwiftUI Binding reads current subject value.
• External binding: external Observable<T> → .bind(to: _example) → subject value updates.
• Subscription: user code subscribes to $example to observe changes → events flow out via RxSwift subscription.
Architectural patterns and design principles
• Property-wrapper pattern (Swift feature)
• Reactive Programming (RxSwift)
• Separation of concerns: ViewModel logic stays Rx-based, SwiftUI remains unaware of Combine.
• Testable units: property wrapper behavior verified in RxPublishedTests.
• Component labels: exactly match code names (e.g., @RxPublished, _example, $example)
• A note on tests: “RxPublishedTests validates subject emissions and subscription behavior”