Check whether loading runs inside LaunchedEffect(Unit). That effect does not restart merely because a captured lesson ID changes while the same call remains in composition.
For composition-owned suspending work, key the effect to the resource identity:
LaunchedEffect(lessonId) {
// loadLesson suspends here and cooperates with cancellation.
loadLesson(lessonId)
}
Changing the key cancels the previous effect coroutine and launches another. If loadLesson launches an unrelated job and returns immediately, cancellation of the effect does not automatically cancel that independent job. Trace the actual ownership of the request.
For screen data, a ViewModel can own the selected ID and loading pipeline instead. Avoid starting the same request from both a ViewModel initializer and a UI effect. Define one owner, a loading state, and a stale-response policy.
What if only a completion callback changes? rememberUpdatedState can let ongoing work use a current callback without restarting it. Do not use that technique to hide a resource ID that genuinely should restart the work.
Mark this when you can explain the answer in your own words.
Help fellow developers prepare for interviews
Sharing helps the Android community grow ๐