slackhq/compose-lints

Lint to use collectAsStateWithLifecycle() instead of just collectAsState()

hrach opened this issue · 3 comments

hrach commented

Would this lint fit this repository?

Can you expand more on its use? When should you use it vs collectAsState?

hrach commented

We think about it the other way around - considering why it shouldn't be used.

Just today we experienced this:

  • we have a main (single activity like) activity with a bottom navigation bar and nested graphs
  • launching a login flow opens a different activity with own nav graph
  • logging in in that activity
  • change of the user state is propagated to the original activity where it is observed, even when the activity is stopped right now

I think this is too heavy-handed and going to decline this. Not every composable use of remember is going to live in an activity