<@U21LBQBU2> I use Rxjava and Rebinding by Jake Wh...
# anko
y
@bj0 I use Rxjava and Rebinding by Jake Wharton, I subscribe to the observables from my view model which I pass in as a constructor parameters (from dagger) within the anko view. When defining the layout in anko, inside the init block, I grab the relevant observables from the view model, I grab an Action1 object from the view model (these are basically handles that handle button clicks and text changes) and then subscribe to the view model observables using the corresponding action from the UI elements. For example, lets say I have an observable in my viewModel that represents the current users GPS location as a pair of latitude and longitude. I would do something like
Copy code
textView {
viewModel.gpsObservable.subscribe(text())
}
Where text() is an extension function on the textView object that you can get from the RXbinding library. It returns an action object with a string parameter that when called, sets the text on that view. So simply subscribing to the view model observables with the corresponding action object from the view let's you get data binding. If you don't wanna use RX, you could probably use the Observable delegate included in kotlin and you can pass a callback into the delegate but I think that's more work. I'll post a code sample when I have access to a computer