Should related reactive properties update each other
Here's code that a user might write:
runtime.add(draggable, view);
ReactiveProperty.of(view, CENTER).subscribe( value -> {
log(value);
})
This wouldn't work because Draggable writes to the view's TRANSLATION instead of CENTER. However, the user may expect this to work.
In Swift we document which properties our view-based interactions affect.
Would be great if android followed the same convention as iOS. I don't have to know anything about CENTER or TRANSLATION options.
runtime.get(block.layer).position.subscribeToValue { (p: CGPoint) in
log(p.x)
}
iOS has the same underlying problem, unfortunately. For example:
var position = runtime.get(block.layer).position
var positionX = runtime.get(block.layer).positionX
position.subscribeToValue { (p: CGPoint) in
log(p.x)
}
positionX.write(0.5) // Error: Nothing is logged even though position's value has changed.
The iOS example you provided works because you happen to subscribe to the same property (position) that Draggable modifies (position). If you subscribed to a different property (positionX), then you would run into the same issues even though positionX and position are related. Like Jeff said, documentation is the easiest way to solve this issue on both platforms. A more involved solution would involve creating a graph of properties that are related to each other.