reactive-cocoa-3

Simple observable struct with RxSwift?

空扰寡人 提交于 2019-12-01 10:09:50
问题 I'm trying to come up with a simple observable object in Swift and thought to use RxSwift. I couldn't find a simple example to do something like this: protocol PropertyObservable { typealias PropertyType var propertyChanged: Event<(PropertyType, Any)> { get } } class Car: PropertyObservable { typealias PropertyType = CarProperty let propertyChanged = Event<(CarProperty, Any)>() dynamic var miles: Int = 0 { didSet { propertyChanged.raise(.Miles, oldValue as Any) } } dynamic var name: String =