Reputation: 391
Reactive BehaviorSubject has a modify method while exposes the values as inout and allows you to modify them. Any RxSwift property that allows similar behaviour?
Upvotes: 0
Views: 302
Reputation: 1995
I'm not aware of any property that allows this, but you could write your own extension for this.
extension BehaviorRelay {
var inoutValue: Element {
get { return value }
set { accept(newValue) }
}
}
// for example
extension BehaviorRelay where Element == Int {
func increment() {
inoutValue += 1
}
}
Upvotes: 1