manas-chaudhari / android-mvvm

MVVM on Android using RxJava and Data Binding
Apache License 2.0
501 stars 81 forks source link

[Discussion] Should BindingAdapters be moved to library #17

Closed manas-chaudhari closed 8 years ago

manas-chaudhari commented 8 years ago

Currently, BindingAdapters for setting up RecyclerView from items and view_provider are in sample. Although binding to recyclerView is quite straight forward, adapters with manual lifecycle requires additional setup, which could be easy to miss.

Proposal: Add a static setup method for configuring default binding. This will have to be invoked in application's setup MVVM.setDefaultBinder(view, vm -> view.setVariable(BR.vm, vm))

Then these binding adapters can be added to the library

Thus, clients will only need to configure the defaultBinder and they should be ready to start using databinding attributes.

manas-chaudhari commented 8 years ago

@sha2nkk What do you think about this?

sha2nkk commented 8 years ago

Yes moving that would remove some of boiler plate and additional setup that user has to write about RecyclerView/ViewPager,

Other than layout_vertical , rest can be moved as it required for customization

manas-chaudhari commented 8 years ago

User can always write his own bindingadapters. When setting viewadapters though such as recyclerview, it is necessary to call binding adapters in the library.

Though if there are any customisations to viewadapters, they can be incorporated in the library. On Wed, 20 Jul 2016 at 12:09 AM, Shashank Kumar notifications@github.com wrote:

Yes moving that would remove some of boiler plate and additional setup that user has to write about RecyclerView/ViewPager,

But will reduce the customization options for recyclerView like Layout manager, ItemDecorator etc. Would be some way user would extend current setup

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/manas-chaudhari/android-mvvm/issues/17#issuecomment-233726423, or mute the thread https://github.com/notifications/unsubscribe-auth/AEJL3GiWS_ojDYEdhZySUHjxIF7oZEI9ks5qXRnPgaJpZM4JOvTz .