Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Should related reactive properties update each other #71

Open
pingpongboss opened this issue Apr 18, 2017 · 3 comments
Open

Should related reactive properties update each other #71

pingpongboss opened this issue Apr 18, 2017 · 3 comments

Comments

@pingpongboss
Copy link
Contributor

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.

@jverkoey
Copy link

In Swift we document which properties our view-based interactions affect.

@randcode-generator
Copy link
Contributor

randcode-generator commented Apr 19, 2017

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)
}

@pingpongboss
Copy link
Contributor Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants