Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notifyChange is an anti pattern #410

Open
MRezaNasirloo opened this issue Oct 12, 2021 · 0 comments
Open

notifyChange is an anti pattern #410

MRezaNasirloo opened this issue Oct 12, 2021 · 0 comments

Comments

@MRezaNasirloo
Copy link

Item.notifyChange is a very handy method when one does not want the hassle of calling diff util, however, this handy method breaks the unidirectional data flow technique.

possible issues

  • Since there isn't a way to backpressure these events, having a few of these will cause an IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
  • This promotes a bad way of state management, one shall not change the UI state inside the UI itself, items should only describe the view and communicate state-related events to the upper layers like ViewModel/Presenter, the rest is their responsibility

Describe the solution you'd like

Deprecate Item.notifyChange method

Additional context

We are heavily using groupie in our codebase and the single source of our bugs and headaches is around this method. Unfortunately, we haven't set a lint rule to not use it and now a good portion of our code is affected by this method.

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

No branches or pull requests

1 participant