Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Collection should match the UI lifecycle so invisible or destroyed views do not keep unnecessary observers alive. Use lifecycle-aware collection appropriate to the UI toolkit.
For Views, repeatOnLifecycle can restart collection when the owner reaches a selected state and cancel it below that state. Use the Fragment view lifecycle for view-bound work rather than retaining a destroyed view. In Compose, collectAsStateWithLifecycle supports lifecycle-aware state collection. Remember that stopping a collector does not necessarily stop a shared producer; configure its owner and sharing policy too.