I'm noticing a common thing that happens is ending up with split-second "loading" states in the app when some data retrieval is async, but the operation ends up being fast (e.g. network request normally, but cached data arrives). So for example, I press the refresh button, the thing being refreshed shows a spinner, but only for 200ms, then it actually loads, making the spinner flash which isn't nice.
Is there a recommended how to avoid this, i.e. skip displaying the loading state unless it's been loading for at least 0.5s?
First thought that comes to mind is debouncing a flow; but I wonder if there's other options which are more on the composable side? Maybe an animation with a delay if the state is loading (as the real state would cancel the animation)?