manas-chaudhari / android-mvvm

MVVM on Android using RxJava and Data Binding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Discussion] Should BindingAdapters be moved to library

manas-chaudhari opened this issue · comments

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

  • items, view_provider, binder
  • items, view_provider (Use default binder)
  • BindingConversion: layout_res to ViewProvider

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

@sha2nkk What do you think about this?

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

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
#17 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEJL3GiWS_ojDYEdhZySUHjxIF7oZEI9ks5qXRnPgaJpZM4JOvTz
.