Chris Arriola
Apr 4, 2023

--

The reason recomposition still happens is due to performance optimizations mentioned in the blog post. If you instead dispose the composition when the view goes off screen, that is worst for performance.

In terms of accessing a viewmodel, my recommendation is to only pass the state that the composable needs rather than the whole VM (VMs should only be passed at the screen-level composable). That follows our architecture best practices and protects you from edge cases like this

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Chris Arriola
Chris Arriola

Written by Chris Arriola

Android Engineer at Instagram Previously: Android Developer Relations Engineer at Google

No responses yet

Write a response